tweaks
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sindre Sorhus · committed by Sindre Sorhus · parent b65479c · Browse files · 3 files·+18 added−12 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+18 added−12 removed
- other:+18 added−12 removed
Provenance
- Commit
e3505a8- Tree
d6f4b3c- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
b65479c
3 files changed+18 added−12 removed
modified:package.json+8 added-2 removed
12344567815 unmodified lines24252627282930313032333435363738394010 unmodified lines{ "name": "execa", "version": "0.1.1", "description": "A better child_process.{execFile,exec}", "description": "A better `child_process`", "license": "MIT", "repository": "sindresorhus/execa", "author": { "name": "Sindre Sorhus",15 unmodified lines "fork", "child", "process", "execfile", "spawn", "file", "shell", "bin", "binary" "binary", "binaries", "npm", "path", "local" ], "dependencies": { "cross-spawn-async": "^2.1.1", "npm-run-path": "^1.0.0",10 unmodified linesmodified:readme.md+1 added-1 removed
1233456795 unmodified lines# execa [](https://travis-ci.org/sindresorhus/execa)
> A better [`child_process.{execFile,exec}`](https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback)> A better [`child_process`](https://nodejs.org/api/child_process.html)
## Why
95 unmodified linesmodified:test.js+9 added-9 removed
122345567891010111213141516171718192021222324252526272829303031323334343536373839394041424344444546import test from 'ava';import fn from './';import m from './';
test('execa()', async t => { const {stdout} = await fn('echo', ['foo']); const {stdout} = await m('echo', ['foo']); t.is(stdout, 'foo');});
test('buffer', async t => { const {stdout} = await fn('echo', ['foo'], {encoding: null}); const {stdout} = await m('echo', ['foo'], {encoding: null}); t.true(Buffer.isBuffer(stdout)); t.is(stdout.toString(), 'foo');});
test('stdout/stderr available on errors', async t => { try { await fn('exit', ['2']); await m('exit', ['2']); } catch (err) { t.is(typeof err.stdout, 'string'); t.is(typeof err.stdout, 'string'); }});
test('execa.shell()', async t => { const {stdout} = await fn.shell('echo foo'); const {stdout} = await m.shell('echo foo'); t.is(stdout, 'foo');});
test('execa.spawn()', t => { t.is(typeof fn.spawn('echo').pid, 'number'); t.is(typeof m.spawn('echo').pid, 'number');});
test('stripEof option', async t => { const {stdout} = await fn('echo', ['foo'], {stripEof: false}); const {stdout} = await m('echo', ['foo'], {stripEof: false}); t.is(stdout, 'foo\n');});
test.serial('preferLocal option', async t => { t.true((await fn('cat-names')).stdout.length > 2); t.true((await m('cat-names')).stdout.length > 2);
// account for npm adding local binaries to the PATH const _path = process.env.PATH; process.env.PATH = ''; await t.throws(fn('cat-names', {preferLocal: false}), /spawn cat-names ENOENT/); await t.throws(m('cat-names', {preferLocal: false}), /spawn cat-names ENOENT/); process.env.PATH = _path;});