Skip to content
Myr

Require Node.js 6

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 7488ce9 · Browse files · 9 files+116 added−116 removed
This commit

State

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

Diff stats

9 files+116 added−116 removed

  • other:+116 added−116 removed

9 files+116 added−116 removed

modified:lib/errname.js+1 added-1 removed
modified:.gitattributes+1 added-2 removed
1* text=auto2*.js text eol=lf1* text=auto eol=lf
modified:.gitignore+1 added
1node_modules2yarn.lock3.nyc_output4coverage
added:.npmrc+1 added
1package-lock=false
modified:.travis.yml+1 added-3 removed
modified:appveyor.yml+1 added-1 removed
modified:index.js+4 added-8 removed
306 unmodified lines
307308 return spawned;309};310311module.exports.stdout = function (...args) {312 // TODO: set `stderr: 'ignore'` when that option is implemented313 return module.exports(...args).then(x => x.stdout);311// TODO: set `stderr: 'ignore'` when that option is implemented312module.exports.stdout = (...args) => module.exports(...args).then(x => x.stdout);314};313316module.exports.stderr = function (...args) {317 // TODO: set `stdout: 'ignore'` when that option is implemented318 return module.exports(...args).then(x => x.stderr);314// TODO: set `stdout: 'ignore'` when that option is implemented315module.exports.stderr = (...args) => module.exports(...args).then(x => x.stderr);319};316317module.exports.shell = (cmd, opts) => handleShell(module.exports, cmd, opts);318319module.exports.sync = (cmd, args, opts) => {
37 unmodified lines
modified:package.json+67 added-74 removed
modified:readme.md+39 added-27 removed
28 unmodified lines
2930```js31const execa = require('execa');3233execa('echo', ['unicorns']).then(result => {34 console.log(result.stdout);33(async () => {34 const {stdout} = await execa('echo', ['unicorns']);35 console.log(stdout);36 //=> 'unicorns'36});37})();38```3938// pipe the child process stdout to the current stdout39execa('echo', ['unicorns']).stdout.pipe(process.stdout);40Additional examples:4141execa.shell('echo unicorns').then(result => {42 console.log(result.stdout);42```js43const execa = require('execa');4445(async () => {46 // Pipe the child process stdout to the current stdout47 execa('echo', ['unicorns']).stdout.pipe(process.stdout);484950 // Run a shell command51 const {stdout} = await execa.shell('echo unicorns');52 //=> 'unicorns'44});535455 // Catching an error56 try {46// example of catching an error47execa.shell('exit 3').catch(error => {48 console.log(error);49 /*50 {51 message: 'Command failed: /bin/sh -c exit 3'52 killed: false,53 code: 3,54 signal: null,55 cmd: '/bin/sh -c exit 3',56 stdout: '',57 stderr: '',58 timedOut: false57 await execa.shell('exit 3');58 } catch (error) {59 console.log(error);60 /*61 {62 message: 'Command failed: /bin/sh -c exit 3'63 killed: false,64 code: 3,65 signal: null,66 cmd: '/bin/sh -c exit 3',67 stdout: '',68 stderr: '',69 timedOut: false70 }71 */72 }60 */61});73})();7463// example of catching an error with a sync method75// Catching an error with a sync method76try {77 execa.shellSync('exit 3');66} catch (err) {67 console.log(err);78} catch (error) {79 console.log(error);80 /*81 {82 message: 'Command failed: /bin/sh -c exit 3'83 code: 3,
80 unmodified lines
164Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.165166#### stdio167156Type: `Array` `string`<br>168Type: `string[]` `string`<br>169Default: `pipe`170171Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.172
148 unmodified lines