Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make error.killed more consistent #248

Merged
merged 4 commits into from May 14, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -432,7 +432,8 @@ module.exports.sync = (command, args, options) => {
joinedCommand,
parsed,
timedOut: false,
isCanceled: false
isCanceled: false,
killed: result.signal !== null
});

if (!parsed.options.reject) {
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Expand Up @@ -113,7 +113,8 @@ try {
stderr: null,
failed: true,
timedOut: false,
isCanceled: false
isCanceled: false,
killed: false
}
*/
}
Expand Down
10 changes: 10 additions & 0 deletions test.js
Expand Up @@ -318,6 +318,16 @@ test('result.killed is false if not killed, in sync mode', t => {
t.false(result.killed);
});

test('result.killed is false on process error', async t => {
const {killed} = await t.throwsAsync(execa('wrong command'));
t.false(killed);
});

test('result.killed is false on process error, in sync mode', t => {
const {killed} = t.throws(() => execa.sync('wrong command'));
ehmicky marked this conversation as resolved.
Show resolved Hide resolved
t.false(killed);
});

if (process.platform === 'darwin') {
test.cb('sanity check: child_process.exec also has killed.false if killed indirectly', t => {
const cp = childProcess.exec('forever', error => {
Expand Down