Skip to content

Commit

Permalink
Fix Windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 10, 2019
1 parent c5cb96c commit f69b579
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions index.js
Expand Up @@ -173,7 +173,7 @@ function getStream(process, stream, {encoding, buffer, maxBuffer}) {
function makeError(result, options) {
const {stdout, stderr, code, signal} = result;
let {error} = result;
const {joinedCommand, timedOut, isCanceled, parsed: {options: {timeout}}} = options;
const {joinedCommand, timedOut, isCanceled, killed, parsed: {options: {timeout}}} = options;

const [exitCodeName, exitCode] = getCode(result, code);

Expand All @@ -194,10 +194,10 @@ function makeError(result, options) {
// `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize
// it to `undefined`
error.signal = signal || undefined;
error.killed = signal !== null && !timedOut;
error.command = joinedCommand;
error.timedOut = Boolean(timedOut);
error.isCanceled = isCanceled;
error.killed = killed && !timedOut;

if ('all' in result) {
error.all = result.all;
Expand Down Expand Up @@ -364,7 +364,8 @@ const execa = (command, args, options) => {
joinedCommand,
parsed,
timedOut,
isCanceled
isCanceled,
killed: spawned.killed
});

if (!parsed.options.reject) {
Expand Down
4 changes: 2 additions & 2 deletions test.js
Expand Up @@ -330,7 +330,7 @@ test('error.killed is true if process was killed directly', async t => {
t.true(error.killed);
});

test('error.killed is true if process was killed indirectly', async t => {
test('error.killed is false if process was killed indirectly', async t => {
const cp = execa('forever');

setTimeout(() => {
Expand All @@ -340,7 +340,7 @@ test('error.killed is true if process was killed indirectly', async t => {
// `process.kill()` is emulated by Node.js on Windows
const message = process.platform === 'win32' ? /failed with exit code 1/ : /was killed with SIGINT/;
const error = await t.throwsAsync(cp, {message});
t.true(error.killed);
t.false(error.killed);
});

if (process.platform === 'darwin') {
Expand Down

0 comments on commit f69b579

Please sign in to comment.