Skip to content

Commit

Permalink
Turn off echo on Windows - fixes #116 (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren authored and sindresorhus committed Dec 31, 2017
1 parent 5f890ab commit ff76235
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions fixtures/hello.cmd
@@ -0,0 +1 @@
ECHO Hello World
6 changes: 6 additions & 0 deletions index.js
@@ -1,4 +1,5 @@
'use strict';
const path = require('path');
const childProcess = require('child_process');
const util = require('util');
const crossSpawn = require('cross-spawn');
Expand Down Expand Up @@ -59,6 +60,11 @@ function handleArgs(cmd, args, opts) {
opts.cleanup = false;
}

if (process.platform === 'win32' && path.basename(parsed.command) === 'cmd.exe') {
// #116
parsed.args.unshift('/q');
}

return {
cmd: parsed.command,
args: parsed.args,
Expand Down
8 changes: 8 additions & 0 deletions test.js
Expand Up @@ -17,6 +17,14 @@ test('execa()', async t => {
t.is(stdout, 'foo');
});

if (process.platform === 'win32') {
test('execa() - cmd file', async t => {
const {stdout} = await m('hello.cmd');

t.is(stdout, 'Hello World');
});
}

test('buffer', async t => {
const {stdout} = await m('noop', ['foo'], {encoding: null});
t.true(Buffer.isBuffer(stdout));
Expand Down

0 comments on commit ff76235

Please sign in to comment.