Skip to content
Myr

Throw error in sync method - fixes #66 (#67)

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

authored by Sam Verschueren · committed by Sindre Sorhus · parent 1a41fac · Browse files · 3 files+10 added−0 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+10 added−0 removed

  • other:+10 added−0 removed

3 files+10 added−0 removed

modified:index.js+4 added
262 unmodified lines
263 }264265 const result = childProcess.spawnSync(parsed.cmd, parsed.args, parsed.opts);266267 if (result.error || result.status !== 0) {268 throw (result.error || new Error(result.stderr === '' ? result.stdout : result.stderr));269 }270271 result.stdout = handleOutput(parsed.opts, result.stdout);272 result.stderr = handleOutput(parsed.opts, result.stderr);273274 return result;
5 unmodified lines
modified:readme.md+2 added
modified:test.js+4 added
55 unmodified lines
56 const {stdout} = m.sync('noop', ['foo']);57 t.is(stdout, 'foo');58});5960test('execa.sync() throws error if written to stderr', t => {61 t.throws(() => m.sync('foo'), process.platform === 'win32' ? /'foo' is not recognized as an internal or external command/ : 'spawnSync foo ENOENT');62});6364test('execa.shellSync()', t => {65 const {stdout} = m.shellSync('node fixtures/noop foo');66 t.is(stdout, 'foo');67});
292 unmodified lines