Skip to content
Myr

Document all the `child_process` options - fixes #90 (#92)

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 2cbcc5c · Browse files · 1 file+82 added−10 removed
This commit

State

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

Diff stats

1 file+82 added−10 removed

  • other:+82 added−10 removed

1 file+82 added−10 removed

modified:readme.md+82 added-10 removed
62 unmodified lines
63### execa(file, [arguments], [options])6465Execute a file.6667Same options as [`child_process.spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).6867Think of this as a mix of `child_process.execFile` and `child_process.spawn`.6869Returns a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess), which is enhanced to also be a `Promise` for a result `Object` with `stdout` and `stderr` properties.70
8 unmodified lines
79### execa.shell(command, [options])8081Execute a command through the system shell. Prefer `execa()` whenever possible, as it's both faster and safer.8285Same options as [`child_process.spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).8683Returns a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess).8485The `child_process` instance is enhanced to also be promise for a result object with `stdout` and `stderr` properties.8687### execa.sync(file, [arguments], [options])8889Execute a file synchronously.9095Same options as [`child_process.spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options), except the default encoding is `utf8` instead of `buffer`.9691Returns the same result object as [`child_process.spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options).9293This method throws an `Error` if the command fails.9495### execa.shellSync(file, [options])9697Execute a command synchronously through the system shell.98105Same options as [`child_process.spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options), except the default encoding is `utf8` instead of `buffer`.10699Returns the same result object as [`child_process.spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options).100101### options102111Additional options:103Type: `Object`104105#### cwd106107Type: `string`<br>108Default: `process.cwd()`109110Current working directory of the child process.111112#### env113114Type: `Object`<br>115Default: `process.env`116117Environment key-value pairs.118119#### argv0120121Type: `string`122123Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.124125#### stdio126127Type: `Array` `string`<br>128Default: `pipe`129130Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.131132#### detached133134Type: `boolean`135136Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).137138#### uid139140Type: `number`141142Sets the user identity of the process.143144#### gid145146Type: `number`147148Sets the group identity of the process.149150#### shell151152Type: `boolean` `string`<br>153Default: `false`154155If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.156157#### stripEof158159Type: `boolean`<br>160Default: `true`
9 unmodified lines
170If you `$ npm install foo`, you can then `execa('foo')`.171172#### input173130Type: `string` `Buffer` `ReadableStream`174Type: `string` `Buffer` `stream.Readable`175176Write some input to the `stdin` of your binary.<br>177Streams are not allowed when using the synchronous methods.178
10 unmodified lines
189Default: `true`190191Keep track of the spawned process and `kill` it when the parent process exits.192193#### encoding194195Type: `string`<br>196Default: `utf8`197198Specify the character encoding used to decode the `stdout` and `stderr` output.199200#### timeout201202Type: `number`<br>203Default: `0`204205If timeout is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than timeout milliseconds.206207#### maxBuffer208209Type: `number`<br>210Default: `10000000` (10MB)211212Largest amount of data in bytes allowed on `stdout` or `stderr`.213214#### killSignal215216Type: `string` `number`<br>217Default: `SIGTERM`218219Signal value to be used when the spawned process will be killed.220221#### stdin222223Type: `string` `number` `Stream` `undefined` `null`<br>224Default: `pipe`
41 unmodified lines