Skip to content
Myr

Make `error.killed` more consistent (#248)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by Sindre Sorhus · parent 0097423 · Browse files · 3 files+22 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+22 added−4 removed

  • other:+22 added−4 removed

3 files+22 added−4 removed

modified:index.js+2 added-1 removed
430 unmodified lines
431 const error = makeError(result, {432 joinedCommand,433 parsed,434 timedOut: false,435 isCanceled: false435 isCanceled: false,436 killed: result.signal !== null437 });438439 if (!parsed.options.reject) {440 return error;
18 unmodified lines
modified:readme.md+2 added-1 removed
111 unmodified lines
112 stdout: null,113 stderr: null,114 failed: true,115 timedOut: false,116 isCanceled: false116 isCanceled: false,117 killed: false118 }119 */120}121```
309 unmodified lines
modified:test.js+18 added-2 removed
139 unmodified lines
140 t.is(stdout, 'foo');141});142143test('stripFinalNewline in sync mode on failure', t => {144 const {stderr} = t.throws(() => execa.sync('noop-throw', ['foo'], {stripFinalNewline: true}));144 const {stderr} = t.throws(() => {145 execa.sync('noop-throw', ['foo'], {stripFinalNewline: true});146 });147 t.is(stderr, 'foo');148});149150test('preferLocal option', async t => {
168 unmodified lines
319 const result = execa.sync('noop');320 t.false(result.killed);321});322323test('result.killed is false on process error', async t => {324 const {killed} = await t.throwsAsync(execa('wrong command'));325 t.false(killed);326});327328test('result.killed is false on process error, in sync mode', t => {329 const {killed} = t.throws(() => {330 execa.sync('wrong command');331 });332 t.false(killed);333});334335if (process.platform === 'darwin') {336 test.cb('sanity check: child_process.exec also has killed.false if killed indirectly', t => {337 const cp = childProcess.exec('forever', error => {338 t.truthy(error);
287 unmodified lines
626 t.false(result.isCanceled);627});628629test('result.isCanceled is false when spawned.cancel() isn\'t called in sync mode (failure)', t => {616 const error = t.throws(() => execa.sync('fail'));630 const error = t.throws(() => {631 execa.sync('fail');632 });633 t.false(error.isCanceled);634});635636test('calling cancel method throws an error with message "Command was canceled"', async t => {
41 unmodified lines