Skip to content
Myr

Separate core options from execa-specific options (#256)

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

authored by ehmicky · committed by Sindre Sorhus · parent 50e3ef4 · Browse files · 3 files+177 added−173 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+177 added−173 removed

  • other:+177 added−173 removed

3 files+177 added−173 removed

modified:index.d.ts+69 added-69 removed
12 unmodified lines
13 | undefined;1415 interface CommonOptions<EncodingType> {16 /**17 Current working directory of the child process.17 Kill the spawned process when the parent process exits unless either:18 - the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)19 - the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit2019 @default process.cwd()21 @default true22 */21 readonly cwd?: string;23 readonly cleanup?: boolean;2425 /**24 Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.26 Prefer locally installed binaries when looking for a binary to execute.2726 @default process.env28 If you `$ npm install foo`, you can then `execa('foo')`.2930 @default true31 */28 readonly env?: NodeJS.ProcessEnv;32 readonly preferLocal?: boolean;3334 /**31 Set to `false` if you don't want to extend the environment variables when providing the `env` property.35 Preferred path to find locally installed binaries in (use with `preferLocal`).3633 @default true37 @default process.cwd()38 */35 readonly extendEnv?: boolean;39 readonly localDir?: string;4041 /**38 Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.42 Buffer the output from the spawned process. When buffering is disabled you must consume the output of the `stdout` and `stderr` streams because the promise will not be resolved/rejected until they have completed.4344 @default true45 */40 readonly argv0?: string;46 readonly buffer?: boolean;4748 /**43 Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.49 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).5051 @default 'pipe'52 */47 readonly stdio?: 'pipe' | 'ignore' | 'inherit' | readonly StdioOption[];53 readonly stdin?: StdioOption;5455 /**50 Prepare 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).56 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).5752 @default false58 @default 'pipe'59 */54 readonly detached?: boolean;60 readonly stdout?: StdioOption;6162 /**57 Sets the user identity of the process.58 */59 readonly uid?: number;63 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).6461 /**62 Sets the group identity of the process.65 @default 'pipe'66 */64 readonly gid?: number;67 readonly stderr?: StdioOption;6869 /**67 If `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.70 Setting this to `false` resolves the promise with the error instead of rejecting it.7169 We recommend against using this option since it is:70 - not cross-platform, encouraging shell-specific syntax.71 - slower, because of the additional shell interpretation.72 - unsafe, potentially allowing command injection.7374 @default false72 @default true73 */76 readonly shell?: boolean | string;74 readonly reject?: boolean;7576 /**77 Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.78
1 unmodified line
80 */81 readonly stripFinalNewline?: boolean;8283 /**86 Prefer locally installed binaries when looking for a binary to execute.84 Set to `false` if you don't want to extend the environment variables when providing the `env` property.8588 If you `$ npm install foo`, you can then `execa('foo')`.8986 @default true87 */92 readonly preferLocal?: boolean;88 readonly extendEnv?: boolean;8990 /**95 Preferred path to find locally installed binaries in (use with `preferLocal`).91 Current working directory of the child process.9293 @default process.cwd()94 */99 readonly localDir?: string;95 readonly cwd?: string;9697 /**102 Setting this to `false` resolves the promise with the error instead of rejecting it.98 Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.99104 @default true100 @default process.env101 */106 readonly reject?: boolean;102 readonly env?: NodeJS.ProcessEnv;103104 /**109 Kill the spawned process when the parent process exits unless either:110 - the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)111 - the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit112113 @default true105 Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.106 */115 readonly cleanup?: boolean;107 readonly argv0?: string;108109 /**118 Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.110 Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.111120 @default 'utf8'112 @default 'pipe'113 */122 readonly encoding?: EncodingType;114 readonly stdio?: 'pipe' | 'ignore' | 'inherit' | readonly StdioOption[];115116 /**125 If `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.117 Prepare 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).118127 @default 0119 @default false120 */129 readonly timeout?: number;121 readonly detached?: boolean;122123 /**132 Buffer the output from the spawned process. When buffering is disabled you must consume the output of the `stdout` and `stderr` streams because the promise will not be resolved/rejected until they have completed.124 Sets the user identity of the process.125 */126 readonly uid?: number;127134 @default true128 /**129 Sets the group identity of the process.130 */136 readonly buffer?: boolean;131 readonly gid?: number;132133 /**139 Largest amount of data in bytes allowed on `stdout` or `stderr`. Default: 10MB.134 If `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.135141 @default 10000000136 We recommend against using this option since it is:137 - not cross-platform, encouraging shell-specific syntax.138 - slower, because of the additional shell interpretation.139 - unsafe, potentially allowing command injection.140141 @default false142 */143 readonly maxBuffer?: number;143 readonly shell?: boolean | string;144145 /**146 Signal value to be used when the spawned process will be killed.146 Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.147148 @default 'SIGTERM'148 @default 'utf8'149 */150 readonly killSignal?: string | number;150 readonly encoding?: EncodingType;151152 /**153 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).153 If `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.154155 @default 'pipe'155 @default 0156 */157 readonly stdin?: StdioOption;157 readonly timeout?: number;158159 /**160 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).160 Largest amount of data in bytes allowed on `stdout` or `stderr`. Default: 10MB.161162 @default 'pipe'162 @default 10000000163 */164 readonly stdout?: StdioOption;164 readonly maxBuffer?: number;165166 /**167 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).167 Signal value to be used when the spawned process will be killed.168169 @default 'pipe'169 @default 'SIGTERM'170 */171 readonly stderr?: StdioOption;171 readonly killSignal?: string | number;172173 /**174 If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.175
198 unmodified lines
modified:index.test-d.ts+25 added-25 removed
modified:readme.md+83 added-79 removed
227 unmodified lines
228### options229230Type: `object`231232#### cwd232#### cleanup233234Type: `boolean`<br>235Default: `true`236237Kill the spawned process when the parent process exits unless either:238 - the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)239 - the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit240241#### preferLocal242243Type: `boolean`<br>244Default: `true`245246Prefer locally installed binaries when looking for a binary to execute.<br>247If you `$ npm install foo`, you can then `execa('foo')`.248249#### localDir250251Type: `string`<br>252Default: `process.cwd()`253237Current working directory of the child process.254Preferred path to find locally installed binaries in (use with `preferLocal`).255239#### env256#### buffer257241Type: `object`<br>242Default: `process.env`258Type: `boolean`<br>259Default: `true`260244Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.261Buffer the output from the spawned process. When buffering is disabled you must consume the output of the `stdout` and `stderr` streams because the promise will not be resolved/rejected until they have completed.262263#### input264265Type: `string | Buffer | stream.Readable`266267Write some input to the `stdin` of your binary.<br>268Streams are not allowed when using the synchronous methods.269270#### stdin271272Type: `string | number | Stream | undefined`<br>273Default: `pipe`274275Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).276277#### stdout278279Type: `string | number | Stream | undefined`<br>280Default: `pipe`281282Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).283284#### stderr285286Type: `string | number | Stream | undefined`<br>287Default: `pipe`288289Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).290291#### reject292293Type: `boolean`<br>294Default: `true`295296Setting this to `false` resolves the promise with the error instead of rejecting it.297298#### stripFinalNewline299300Type: `boolean`<br>301Default: `true`302303Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.304305#### extendEnv306307Type: `boolean`<br>308Default: `true`309310Set to `false` if you don't want to extend the environment variables when providing the `env` property.311312---313314Execa also accepts the below options which are the same as the options for [`child_process#spawn()`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)/[`child_process#exec()`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)315316#### cwd317318Type: `string`<br>319Default: `process.cwd()`320321Current working directory of the child process.322323#### env324325Type: `object`<br>326Default: `process.env`327328Environment key-value pairs. Extends automatically from `process.env`. Set [`extendEnv`](#extendenv) to `false` if you don't want this.329330#### argv0331332Type: `string`333
35 unmodified lines
369- not cross-platform, encouraging shell-specific syntax.370- slower, because of the additional shell interpretation.371- unsafe, potentially allowing command injection.372296#### stripFinalNewline297298Type: `boolean`<br>299Default: `true`300301Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.302303#### preferLocal304305Type: `boolean`<br>306Default: `true`307308Prefer locally installed binaries when looking for a binary to execute.<br>309If you `$ npm install foo`, you can then `execa('foo')`.310311#### localDir312313Type: `string`<br>314Default: `process.cwd()`315316Preferred path to find locally installed binaries in (use with `preferLocal`).317318#### input319320Type: `string | Buffer | stream.Readable`321322Write some input to the `stdin` of your binary.<br>323Streams are not allowed when using the synchronous methods.324325#### reject326327Type: `boolean`<br>328Default: `true`329330Setting this to `false` resolves the promise with the error instead of rejecting it.331332#### cleanup333334Type: `boolean`<br>335Default: `true`336337Kill the spawned process when the parent process exits unless either:338 - the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)339 - the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit340373#### encoding374375Type: `string | null`<br>376Default: `utf8`
6 unmodified lines
383Default: `0`384385If 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.386355#### buffer356357Type: `boolean`<br>358Default: `true`359360Buffer the output from the spawned process. When buffering is disabled you must consume the output of the `stdout` and `stderr` streams because the promise will not be resolved/rejected until they have completed.361387#### maxBuffer388389Type: `number`<br>390Default: `10000000` (10MB)
6 unmodified lines
397Default: `SIGTERM`398399Signal value to be used when the spawned process will be killed.400376#### stdin377378Type: `string | number | Stream | undefined`<br>379Default: `pipe`380381Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).382383#### stdout384385Type: `string | number | Stream | undefined`<br>386Default: `pipe`387388Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).389390#### stderr391392Type: `string | number | Stream | undefined`<br>393Default: `pipe`394395Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).396401#### windowsVerbatimArguments402403Type: `boolean`<br>404Default: `false`
28 unmodified lines