Skip to content
Myr

[BREAKING] for consistency return a result object from `execa.sync()` instead of string (#22)

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

fixes #19

authored by James Talmage · committed by Sindre Sorhus · parent 99f10ba · Browse files · 3 files+13 added−8 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+13 added−8 removed

  • other:+13 added−8 removed

3 files+13 added−8 removed

modified:index.js+7 added-2 removed
modified:readme.md+2 added-2 removed
85 unmodified lines
86Execute a file synchronously.8788Same options as [`child_process.execFileSync`](https://nodejs.org/api/child_process.html#child_process_child_process_execfilesync_file_args_options), except the default encoding is `utf8` instead of `buffer`.8990Returns `stdout`.90Returns the same result object as [`child_process.spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options).9192### execa.shellSync(file, [options])9394Execute a command synchronously through the system shell.9596Same options as [`child_process.execSync`](https://nodejs.org/api/child_process.html#child_process_child_process_execsync_command_options), except the default encoding is `utf8` instead of `buffer`.9798Returns `stdout`.98Returns the same result object as [`child_process.spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options).99100### options101102Additional options:
27 unmodified lines
modified:test.js+4 added-4 removed
37 unmodified lines
38 t.is((await getStream(m.spawn('noop', ['foo']).stdout)).trim(), 'foo');39});4041test('execa.sync()', t => {42 const stdout = m.sync('noop', ['foo']);42 const {stdout} = m.sync('noop', ['foo']);43 t.is(stdout, 'foo');44});4546test('execa.shellSync()', t => {47 const stdout = m.shellSync('node fixtures/noop foo');47 const {stdout} = m.shellSync('node fixtures/noop foo');48 t.is(stdout, 'foo');49});5051test('stripEof option', async t => {
40 unmodified lines
92 t.is((await child).stdout, 'unicorns');93});9495test('input option can be a String - sync', async t => {96 const stdout = m.sync('stdin', {input: 'foobar'});96 const {stdout} = m.sync('stdin', {input: 'foobar'});97 t.is(stdout, 'foobar');98});99100test('input option can be a Buffer - sync', async t => {101 const stdout = m.sync('stdin', {input: new Buffer('testing12', 'utf8')});101 const {stdout} = m.sync('stdin', {input: new Buffer('testing12', 'utf8')});102 t.is(stdout, 'testing12');103});104105test('helpful error trying to provide an input stream in sync mode', t => {
11 unmodified lines