Skip to content

Commit f69b579

Browse files
committed
Fix Windows support
1 parent c5cb96c commit f69b579

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function getStream(process, stream, {encoding, buffer, maxBuffer}) {
173173
function makeError(result, options) {
174174
const {stdout, stderr, code, signal} = result;
175175
let {error} = result;
176-
const {joinedCommand, timedOut, isCanceled, parsed: {options: {timeout}}} = options;
176+
const {joinedCommand, timedOut, isCanceled, killed, parsed: {options: {timeout}}} = options;
177177

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

@@ -194,10 +194,10 @@ function makeError(result, options) {
194194
// `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize
195195
// it to `undefined`
196196
error.signal = signal || undefined;
197-
error.killed = signal !== null && !timedOut;
198197
error.command = joinedCommand;
199198
error.timedOut = Boolean(timedOut);
200199
error.isCanceled = isCanceled;
200+
error.killed = killed && !timedOut;
201201

202202
if ('all' in result) {
203203
error.all = result.all;
@@ -364,7 +364,8 @@ const execa = (command, args, options) => {
364364
joinedCommand,
365365
parsed,
366366
timedOut,
367-
isCanceled
367+
isCanceled,
368+
killed: spawned.killed
368369
});
369370

370371
if (!parsed.options.reject) {

test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ test('error.killed is true if process was killed directly', async t => {
330330
t.true(error.killed);
331331
});
332332

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

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

346346
if (process.platform === 'darwin') {

0 commit comments

Comments
 (0)