Skip to content
Myr

Fix `error.message` when using `encoding: 'buffer'` (#701)

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

authored by ehmicky · committed by GitHub · parent 214b6ab · Browse files · 2 files+15 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

2 files+15 added−4 removed

  • tests:+6 added−3 removed
  • other:+9 added−1 removed

2 files+15 added−4 removed

modified:lib/error.js+9 added-1 removed
modified:test/error.js+6 added-3 removed
96 unmodified lines
97test('error.message contains the command', async t => {98 await t.throwsAsync(execa('exit.js', ['2', 'foo', 'bar']), {message: /exit.js 2 foo bar/});99});100101test('error.message contains stdout/stderr/stdio if available', async t => {102 const {message} = await t.throwsAsync(execa('echo-fail.js', fullStdio));101const testStdioMessage = async (t, encoding) => {102 const {message} = await t.throwsAsync(execa('echo-fail.js', {...fullStdio, encoding}));103 t.true(message.endsWith('stderr\nstdout\nfd3'));104});104};105106test('error.message contains stdout/stderr/stdio if available', testStdioMessage, 'utf8');107test('error.message contains stdout/stderr/stdio even with encoding "buffer"', testStdioMessage, 'buffer');108109test('error.message does not contain stdout if not available', async t => {110 const {message} = await t.throwsAsync(execa('echo-fail.js', {stdio: ['pipe', 'ignore', 'pipe', 'pipe']}));111 t.true(message.endsWith('stderr\nfd3'));112});
163 unmodified lines