Skip to content
Myr

Improve error messages when an `error` event is emitted (#269)

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 3b103f8 · Browse files · 2 files+11 added−1 removed
This commit

State

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

Diff stats

2 files+11 added−1 removed

  • other:+11 added−1 removed

2 files+11 added−1 removed

modified:index.js+5 added-1 removed
196 unmodified lines
197 if (signal) {198 return `was killed with ${signal}`;199 }200201 if (exitCode !== undefined) {201 return `failed with exit code ${exitCode} (${exitCodeName})`;202 return `failed with exit code ${exitCode} (${exitCodeName})`;203 }204205 return 'failed';206}207208function joinCommand(file, args = []) {209 if (!Array.isArray(args)) {
257 unmodified lines
modified:test.js+6 added
192 unmodified lines
193 const {stdout} = execa.sync('stdin', {input: Buffer.from('testing12', 'utf8')});194 t.is(stdout, 'testing12');195});196197test('child process errors are handled', async t => {198 const child = execa('noop');199 child.emit('error', new Error('test'));200 await t.throwsAsync(child, /Command failed.*\ntest/);201});202203test('opts.stdout:ignore - stdout will not collect data', async t => {204 const {stdout} = await execa('stdin', {205 input: 'hello',206 stdio: [undefined, 'ignore', undefined]
529 unmodified lines