Document and type more `subprocess.*` properties/methods (#968)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 1e9e47e · Browse files · 4 files·+296 added−74 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+296 added−74 removed
- other:+296 added−74 removed
Provenance
- Commit
fe330a9- Tree
027460a- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
1e9e47e
4 files changed+296 added−74 removed
modified:docs/scripts.md+1 added-1 removed
823 unmodified lines824 Execa's scripting API mostly consists of only two methods: [`` $`command` ``](../readme.md#file-arguments-options) and [`$(options)`](../readme.md#execaoptions).825 826 [No special binary](#main-binary) is recommended, no [global variable](#global-variables) is injected: scripts are regular Node.js files.827 828-Execa is a thin wrapper around the core Node.js [`child_process` module](https://nodejs.org/api/child_process.html). Unlike zx, it lets you use [any of its native features](#background-subprocesses): [`pid`](#pid), [IPC](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback), [`unref()`](https://nodejs.org/api/child_process.html#subprocessunref), [`detached`](https://nodejs.org/api/child_process.html#child_processspawncommand-args-options), [`uid`](https://nodejs.org/api/child_process.html#child_processspawncommand-args-options), [`gid`](https://nodejs.org/api/child_process.html#child_processspawncommand-args-options), [`cancelSignal`](https://nodejs.org/api/child_process.html#child_processspawncommand-args-options), etc.828+Execa is a thin wrapper around the core Node.js [`child_process` module](https://nodejs.org/api/child_process.html). Unlike zx, it lets you use [any of its native features](#background-subprocesses): [`pid`](#pid), [IPC](../readme.md#optionsipc), [`unref()`](https://nodejs.org/api/child_process.html#subprocessunref), [`detached`](../readme.md#optionsdetached), [`uid`](../readme.md#optionsuid), [`gid`](../readme.md#optionsgid), [`cancelSignal`](../readme.md#optionscancelsignal), etc.829 830 ### Modularity831 832 zx includes many builtin utilities: `fetch()`, `question()`, `sleep()`, `stdin()`, `retry()`, `spinner()`, `chalk`, `fs-extra`, `os`, `path`, `globby`, `yaml`, `minimist`, `which`, Markdown scripts, remote scripts.16 unmodified linesmodified:index.d.ts+103 added-31 removed
441 unmodified lines442 */443 readonly inputFile?: string | URL;444 445 /**446- [How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard input. This can be:447- - `'pipe'`: Sets [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin) stream.446+ How to setup the subprocess' standard input. This can be:447+ - `'pipe'`: Sets `subprocess.stdin` stream.448 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.449 - `'ignore'`: Do not use `stdin`.450 - `'inherit'`: Re-use the current process' `stdin`.451 - an integer: Re-use a specific file descriptor from the current process.12 unmodified lines464 */465 readonly stdin?: StdinOptionCommon<IsSync>;466 467 /**468- [How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard output. This can be:469- - `'pipe'`: Sets `result.stdout` (as a string or `Uint8Array`) and [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout) (as a stream).468+ How to setup the subprocess' standard output. This can be:469+ - `'pipe'`: Sets `result.stdout` (as a string or `Uint8Array`) and `subprocess.stdout` (as a stream).470 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.471 - `'ignore'`: Do not use `stdout`.472 - `'inherit'`: Re-use the current process' `stdout`.473 - an integer: Re-use a specific file descriptor from the current process.10 unmodified lines484 */485 readonly stdout?: StdoutStderrOptionCommon<IsSync>;486 487 /**488- [How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard error. This can be:489- - `'pipe'`: Sets `result.stderr` (as a string or `Uint8Array`) and [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr) (as a stream).488+ How to setup the subprocess' standard error. This can be:489+ - `'pipe'`: Sets `result.stderr` (as a string or `Uint8Array`) and `subprocess.stderr` (as a stream).490 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.491 - `'ignore'`: Do not use `stderr`.492 - `'inherit'`: Re-use the current process' `stderr`.493 - an integer: Re-use a specific file descriptor from the current process.138 unmodified lines632 633 /**634 Signal used to terminate the subprocess when:635 - using the `cancelSignal`, `timeout`, `maxBuffer` or `cleanup` option636- - calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with no arguments636+ - calling `subprocess.kill()` with no arguments637 638 This can be either a name (like `"SIGTERM"`) or a number (like `9`).639 640 @default 'SIGTERM'6 unmodified lines647 The grace period is 5 seconds by default. This feature can be disabled with `false`.648 649 This works when the subprocess is terminated by either:650 - the `cancelSignal`, `timeout`, `maxBuffer` or `cleanup` option651- - calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with no arguments651+ - calling `subprocess.kill()` with no arguments652 653 This does not work when the subprocess is terminated by either:654- - calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with an argument654+ - calling `subprocess.kill()` with an argument655 - calling [`process.kill(subprocess.pid)`](https://nodejs.org/api/process.html#processkillpid-signal)656 - sending a termination signal from another process657 658 Also, this does not work on Windows, because Windows [doesn't support signals](https://nodejs.org/api/process.html#process_signal_events): `SIGKILL` and `SIGTERM` both terminate the subprocess immediately. Other packages (such as [`taskkill`](https://github.com/sindresorhus/taskkill)) can be used to achieve fail-safe termination on Windows.31 unmodified lines690 readonly verbose?: 'none' | 'short' | 'full';691 692 /**693 Kill the subprocess when the current process exits unless either:694- - the subprocess is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)695- - the current process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit694+ - the subprocess is `detached`.695+ - the current process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit.696 697 @default true698 */699 readonly cleanup?: Unless<IsSync, boolean>;16 unmodified lines716 */717 readonly all?: boolean;718 719 /**720- Enables exchanging messages with the subprocess using [`subprocess.send(value)`](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback) and [`subprocess.on('message', (value) => {})`](https://nodejs.org/api/child_process.html#event-message).720+ Enables exchanging messages with the subprocess using `subprocess.send(message)` and `subprocess.on('message', (message) => {})`.721 722 @default `true` if the `node` option is enabled, `false` otherwise723 */724 readonly ipc?: Unless<IsSync, boolean>;9 unmodified lines734 */735 readonly serialization?: Unless<IsSync, 'json' | 'advanced'>;736 737 /**738- Prepare subprocess to run independently of the current process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).738+ Prepare subprocess to run independently of the current process. Specific behavior depends on the platform.739 740 @default false741 */742 readonly detached?: Unless<IsSync, boolean>;83 unmodified lines826 827 /**828 The output of the subprocess on `stdout`.829 830- This is `undefined` if the `stdout` option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `lines` option is `true`, or if the `stdout` option is a transform in object mode.830+ This is `undefined` if the `stdout` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`. This is an array if the `lines` option is `true`, or if the `stdout` option is a transform in object mode.831 */832 stdout: StdioOutput<'1', OptionsType>;833 834 /**835 The output of the subprocess on `stderr`.836 837- This is `undefined` if the `stderr` option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `lines` option is `true`, or if the `stderr` option is a transform in object mode.837+ This is `undefined` if the `stderr` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`. This is an array if the `lines` option is `true`, or if the `stderr` option is a transform in object mode.838 */839 stderr: StdioOutput<'2', OptionsType>;840 841 /**842 The output of the subprocess on `stdin`, `stdout`, `stderr` and other file descriptors.843 844- Items are `undefined` when their corresponding `stdio` option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). Items are arrays when their corresponding `stdio` option is a transform in object mode.844+ Items are `undefined` when their corresponding `stdio` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`. Items are arrays when their corresponding `stdio` option is a transform in object mode.845 */846 stdio: StdioArrayOutput<OptionsType>;847 848 /**49 unmodified lines898 */899 isMaxBuffer: boolean;900 901 /**902- The output of the subprocess with `stdout` and `stderr` interleaved.902+ The output of the subprocess with `result.stdout` and `result.stderr` interleaved.903 904 This is `undefined` if either:905- - the `all` option is `false` (default value)906- - both `stdout` and `stderr` options are set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)905+ - the `all` option is `false` (default value).906+ - both `stdout` and `stderr` options are set to `'inherit'`, `'ignore'`, `Writable` or `integer`.907 908 This is an array if the `lines` option is `true`, or if either the `stdout` or `stderr` option is a transform in object mode.909 */910 all: AllOutput<OptionsType>;129 unmodified lines1040 > = StreamResultIgnored extends true1041 ? null1042 : InputOutputStream<IsInputStdioDescriptor<FdNumber, OptionsType>>;1043 1044+// Type of `subprocess.stdio`1045+type StdioArrayStreams<OptionsType extends Options = Options> = MapStdioStreams<StdioArrayOption<OptionsType>, OptionsType>;1046+1047+// We cannot use mapped types because it must be compatible with Node.js `ChildProcess["stdio"]` which uses a tuple with exactly 5 items1048+type MapStdioStreams<1049+ StdioOptionsArrayType extends StdioOptionsArray,1050+ OptionsType extends Options = Options,1051+> = [1052+ StreamUnlessIgnored<'0', OptionsType>,1053+ StreamUnlessIgnored<'1', OptionsType>,1054+ StreamUnlessIgnored<'2', OptionsType>,1055+ '3' extends keyof StdioOptionsArrayType ? StreamUnlessIgnored<'3', OptionsType> : never,1056+ '4' extends keyof StdioOptionsArrayType ? StreamUnlessIgnored<'4', OptionsType> : never,1057+];1058+1059 type InputOutputStream<IsInput extends boolean> = IsInput extends true1060 ? Writable1061 : Readable;1062 130 unmodified lines1193 ? Uint8Array1194 : string1195 >;1196 1197+type HasIpc<OptionsType extends Options> = OptionsType['ipc'] extends true1198+ ? true1199+ : OptionsType['stdio'] extends StdioOptionsArray1200+ ? 'ipc' extends OptionsType['stdio'][number] ? true : false1201+ : false;1202+1203 export type ExecaResultPromise<OptionsType extends Options = Options> = {1204+ /**1205+ Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).1206+1207+ This is `undefined` if the subprocess failed to spawn.1208+ */1209+ pid?: number;1210+1211+ /**1212+ Send a `message` to the subprocess. The type of `message` depends on the `serialization` option.1213+ The subprocess receives it as a [`message` event](https://nodejs.org/api/process.html#event-message).1214+1215+ This returns `true` on success.1216+1217+ This requires the `ipc` option to be `true`.1218+1219+ [More info.](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback)1220+ */1221+ send: HasIpc<OptionsType> extends true ? ChildProcess['send'] : undefined;1222+1223+ /**1224+ The subprocess `stdin` as a stream.1225+1226+ This is `null` if the `stdin` option is set to `'inherit'`, `'ignore'`, `Readable` or `integer`.1227+1228+ This is intended for advanced cases. Please consider using the `stdin` option, `input` option, `inputFile` option, or `subprocess.pipe()` instead.1229+ */1230 stdin: StreamUnlessIgnored<'0', OptionsType>;1231 1232+ /**1233+ The subprocess `stdout` as a stream.1234+1235+ This is `null` if the `stdout` option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`.1236+1237+ This is intended for advanced cases. Please consider using `result.stdout`, the `stdout` option, `subprocess.iterable()`, or `subprocess.pipe()` instead.1238+ */1239 stdout: StreamUnlessIgnored<'1', OptionsType>;1240 1241+ /**1242+ The subprocess `stderr` as a stream.1243+1244+ This is `null` if the `stderr` option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`.1245+1246+ This is intended for advanced cases. Please consider using `result.stderr`, the `stderr` option, `subprocess.iterable()`, or `subprocess.pipe()` instead.1247+ */1248 stderr: StreamUnlessIgnored<'2', OptionsType>;1249 1250 /**1190- Stream combining/interleaving [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).1251+ Stream combining/interleaving `subprocess.stdout` and `subprocess.stderr`.1252 1253 This is `undefined` if either:1193- - the `all` option is `false` (the default value)1194- - both `stdout` and `stderr` options are set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)1254+ - the `all` option is `false` (the default value).1255+ - both `stdout` and `stderr` options are set to `'inherit'`, `'ignore'`, `Writable` or `integer`.1256+1257+ This is intended for advanced cases. Please consider using `result.all`, the `stdout`/`stderr` option, `subprocess.iterable()`, or `subprocess.pipe()` instead.1258 */1259 all: AllStream<OptionsType>;1260 1261+ /**1262+ The subprocess `stdin`, `stdout`, `stderr` and other files descriptors as an array of streams.1263+1264+ Each array item is `null` if the corresponding `stdin`, `stdout`, `stderr` or `stdio` option is set to `'inherit'`, `'ignore'`, `Stream` or `integer`.1265+1266+ This is intended for advanced cases. Please consider using `result.stdio`, the `stdio` option, `subprocess.iterable()` or `subprocess.pipe()` instead.1267+ */1268+ stdio: StdioArrayStreams<OptionsType>;1269+1270 catch<ResultType = never>(1271 onRejected?: (reason: ExecaError<OptionsType>) => ResultType | PromiseLike<ResultType>1272 ): Promise<ExecaResult<OptionsType> | ResultType>;1273 23 unmodified lines1297 1298 /**1299 Converts the subprocess to a readable stream.1300 1229- Unlike [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), the stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess fails. This means you do not need to `await` the subprocess' promise. On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options), [`await pipeline(..., stream)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) or [`await text(stream)`](https://nodejs.org/api/webstreams.html#streamconsumerstextstream) which throw an exception when the stream errors.1301+ Unlike `subprocess.stdout`, the stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess fails. This means you do not need to `await` the subprocess' promise. On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options), [`await pipeline(..., stream)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) or [`await text(stream)`](https://nodejs.org/api/webstreams.html#streamconsumerstextstream) which throw an exception when the stream errors.1302 1303 Before using this method, please first consider the `stdin`/`stdout`/`stderr`/`stdio` options, `subprocess.pipe()` or `subprocess.iterable()`.1304 */1305 readable(readableOptions?: ReadableOptions): Readable;1306 1307 /**1308 Converts the subprocess to a writable stream.1309 1238- Unlike [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin), the stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess fails. This means you do not need to `await` the subprocess' promise. On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options) or [`await pipeline(stream, ...)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) which throw an exception when the stream errors.1310+ Unlike `subprocess.stdin`, the stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess fails. This means you do not need to `await` the subprocess' promise. On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options) or [`await pipeline(stream, ...)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) which throw an exception when the stream errors.1311 1312 Before using this method, please first consider the `stdin`/`stdout`/`stderr`/`stdio` options or `subprocess.pipe()`.1313 */1314 writable(writableOptions?: WritableOptions): Writable;7 unmodified lines1322 */1323 duplex(duplexOptions?: DuplexOptions): Duplex;1324 } & PipableSubprocess;1325 1254-export type ExecaSubprocess<OptionsType extends Options = Options> = ChildProcess &1326+export type ExecaSubprocess<OptionsType extends Options = Options> = Omit<ChildProcess, keyof ExecaResultPromise<OptionsType>> &1327 ExecaResultPromise<OptionsType> &1328 Promise<ExecaResult<OptionsType>>;1329 1330 type TemplateExpression = string | number | CommonResultInstance223 unmodified lines1554 1555 Returns or throws a subprocess `result`. The `subprocess` is not returned: its methods and properties are not available.1556 1557 The following features cannot be used:1486-- Streams: [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin), [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr), `subprocess.readable()`, `subprocess.writable()`, `subprocess.duplex()`.1487-- The `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async transform, a `Duplex`, nor a web stream. Node.js streams can be passed but only if either they [have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr), or the `input` option is used.1488-- Signal termination: [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`subprocess.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `cleanup` option, `cancelSignal` option, `forceKillAfterDelay` option.1558+- Streams: `subprocess.stdin`, `subprocess.stdout`, `subprocess.stderr`, `subprocess.readable()`, `subprocess.writable()`, `subprocess.duplex()`.1559+- The `stdin`, `stdout`, `stderr` and `stdio` options cannot be `'overlapped'`, an async iterable, an async transform, a `Duplex`, nor a web stream. Node.js streams can be passed but only if either they [have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr), or the `input` option is used.1560+- Signal termination: `subprocess.kill()`, `subprocess.pid`, `cleanup` option, `cancelSignal` option, `forceKillAfterDelay` option.1561 - Piping multiple processes: `subprocess.pipe()`.1562 - `subprocess.iterable()`.1563 - `ipc` and `serialization` options.1564 - `result.all` is not interleaved.113 unmodified lines1678 1679 Returns or throws a subprocess `result`. The `subprocess` is not returned: its methods and properties are not available.1680 1681 The following features cannot be used:1610-- Streams: [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin), [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr), `subprocess.readable()`, `subprocess.writable()`, `subprocess.duplex()`.1611-- The `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async transform, a `Duplex`, nor a web stream. Node.js streams can be passed but only if either they [have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr), or the `input` option is used.1612-- Signal termination: [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`subprocess.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `cleanup` option, `cancelSignal` option, `forceKillAfterDelay` option.1682+- Streams: `subprocess.stdin`, `subprocess.stdout`, `subprocess.stderr`, `subprocess.readable()`, `subprocess.writable()`, `subprocess.duplex()`.1683+- The `stdin`, `stdout`, `stderr` and `stdio` options cannot be `'overlapped'`, an async iterable, an async transform, a `Duplex`, nor a web stream. Node.js streams can be passed but only if either they [have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr), or the `input` option is used.1684+- Signal termination: `subprocess.kill()`, `subprocess.pid`, `cleanup` option, `cancelSignal` option, `forceKillAfterDelay` option.1685 - Piping multiple processes: `subprocess.pipe()`.1686 - `subprocess.iterable()`.1687 - `ipc` and `serialization` options.1688 - `result.all` is not interleaved.134 unmodified linesmodified:index.test-d.ts+66 added-1 removed
515 unmodified lines516 expectType<string>(unicornsResult.stdio[2]);517 expectType<string>(unicornsResult.all);518 expectType<string | undefined>(unicornsResult.stdio[3 as number]);519 520+ expectType<number | undefined>(execaBufferPromise.pid);521+522+ expectType<boolean>(execa('unicorns', {ipc: true}).send({}));523+ execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ipc']}).send({});524+ execa('unicorns', {stdio: ['pipe', 'pipe', 'ipc', 'pipe']}).send({});525+ execa('unicorns', {ipc: true}).send('message');526+ execa('unicorns', {ipc: true}).send({}, undefined, {keepOpen: true});527+ expectError(execa('unicorns', {ipc: true}).send({}, true));528+ expectType<undefined>(execa('unicorns', {}).send);529+ expectType<undefined>(execa('unicorns', {ipc: false}).send);530+ expectType<undefined>(execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe']}).send);531+532 expectType<Writable>(execaBufferPromise.stdin);533+ expectType<Writable>(execaBufferPromise.stdio[0]);534 expectType<Readable>(execaBufferPromise.stdout);535+ expectType<Readable>(execaBufferPromise.stdio[1]);536 expectType<Readable>(execaBufferPromise.stderr);537+ expectType<Readable>(execaBufferPromise.stdio[2]);538 expectType<Readable>(execaBufferPromise.all);539+ expectError(execaBufferPromise.stdio[3].destroy());540 expectType<Uint8Array>(bufferResult.stdout);541 expectType<Uint8Array>(bufferResult.stdio[1]);542 expectType<Uint8Array>(bufferResult.stderr);543 expectType<Uint8Array>(bufferResult.stdio[2]);544 expectType<Uint8Array>(bufferResult.all);545 546 expectType<Writable>(execaHexPromise.stdin);547+ expectType<Writable>(execaHexPromise.stdio[0]);548 expectType<Readable>(execaHexPromise.stdout);549+ expectType<Readable>(execaHexPromise.stdio[1]);550 expectType<Readable>(execaHexPromise.stderr);551+ expectType<Readable>(execaHexPromise.stdio[2]);552 expectType<Readable>(execaHexPromise.all);553+ expectError(execaHexPromise.stdio[3].destroy());554 expectType<string>(hexResult.stdout);555 expectType<string>(hexResult.stdio[1]);556 expectType<string>(hexResult.stderr);557 expectType<string>(hexResult.stdio[2]);21 unmodified lines579 expectType<string>(linesHexResult.all);580 581 const noBufferPromise = execa('unicorns', {buffer: false, all: true});582 expectType<Writable>(noBufferPromise.stdin);583+ expectType<Writable>(noBufferPromise.stdio[0]);584 expectType<Readable>(noBufferPromise.stdout);585+ expectType<Readable>(noBufferPromise.stdio[1]);586 expectType<Readable>(noBufferPromise.stderr);587+ expectType<Readable>(noBufferPromise.stdio[2]);588 expectType<Readable>(noBufferPromise.all);589+ expectError(noBufferPromise.stdio[3].destroy());590 const noBufferResult = await noBufferPromise;591 expectType<undefined>(noBufferResult.stdout);592 expectType<undefined>(noBufferResult.stdio[1]);593 expectType<undefined>(noBufferResult.stderr);4 unmodified lines598 expectType<Writable>(multipleStdinPromise.stdin);599 600 const multipleStdoutPromise = execa('unicorns', {stdout: ['inherit', 'pipe'] as ['inherit', 'pipe'], all: true});601 expectType<Writable>(multipleStdoutPromise.stdin);602+ expectType<Writable>(multipleStdoutPromise.stdio[0]);603 expectType<Readable>(multipleStdoutPromise.stdout);604+ expectType<Readable>(multipleStdoutPromise.stdio[1]);605 expectType<Readable>(multipleStdoutPromise.stderr);606+ expectType<Readable>(multipleStdoutPromise.stdio[2]);607 expectType<Readable>(multipleStdoutPromise.all);608+ expectError(multipleStdoutPromise.stdio[3].destroy());609 const multipleStdoutResult = await multipleStdoutPromise;610 expectType<string>(multipleStdoutResult.stdout);611 expectType<string>(multipleStdoutResult.stdio[1]);612 expectType<string>(multipleStdoutResult.stderr);1 unmodified line614 expectType<string>(multipleStdoutResult.all);615 616 const ignoreAnyPromise = execa('unicorns', {stdin: 'ignore', stdout: 'ignore', stderr: 'ignore', all: true});617 expectType<null>(ignoreAnyPromise.stdin);618+ expectType<null>(ignoreAnyPromise.stdio[0]);619 expectType<null>(ignoreAnyPromise.stdout);620+ expectType<null>(ignoreAnyPromise.stdio[1]);621 expectType<null>(ignoreAnyPromise.stderr);622+ expectType<null>(ignoreAnyPromise.stdio[2]);623 expectType<undefined>(ignoreAnyPromise.all);624+ expectError(ignoreAnyPromise.stdio[3].destroy());625 const ignoreAnyResult = await ignoreAnyPromise;626 expectType<undefined>(ignoreAnyResult.stdout);627 expectType<undefined>(ignoreAnyResult.stdio[1]);628 expectType<undefined>(ignoreAnyResult.stderr);1 unmodified line630 expectType<undefined>(ignoreAnyResult.all);631 632 const ignoreAllPromise = execa('unicorns', {stdio: 'ignore', all: true});633 expectType<null>(ignoreAllPromise.stdin);634+ expectType<null>(ignoreAllPromise.stdio[0]);635 expectType<null>(ignoreAllPromise.stdout);636+ expectType<null>(ignoreAllPromise.stdio[1]);637 expectType<null>(ignoreAllPromise.stderr);638+ expectType<null>(ignoreAllPromise.stdio[2]);639 expectType<undefined>(ignoreAllPromise.all);640+ expectError(ignoreAllPromise.stdio[3].destroy());641 const ignoreAllResult = await ignoreAllPromise;642 expectType<undefined>(ignoreAllResult.stdout);643 expectType<undefined>(ignoreAllResult.stdio[1]);644 expectType<undefined>(ignoreAllResult.stderr);645 expectType<undefined>(ignoreAllResult.stdio[2]);646 expectType<undefined>(ignoreAllResult.all);647 612- const ignoreStdioArrayPromise = execa('unicorns', {stdio: ['ignore', 'ignore', 'pipe'], all: true});648+ const ignoreStdioArrayPromise = execa('unicorns', {stdio: ['ignore', 'ignore', 'pipe', 'pipe'], all: true});649 expectType<null>(ignoreStdioArrayPromise.stdin);650+ expectType<null>(ignoreStdioArrayPromise.stdio[0]);651 expectType<null>(ignoreStdioArrayPromise.stdout);652+ expectType<null>(ignoreStdioArrayPromise.stdio[1]);653 expectType<Readable>(ignoreStdioArrayPromise.stderr);654+ expectType<Readable>(ignoreStdioArrayPromise.stdio[2]);655 expectType<Readable>(ignoreStdioArrayPromise.all);656+ expectType<Readable>(ignoreStdioArrayPromise.stdio[3]);657 const ignoreStdioArrayResult = await ignoreStdioArrayPromise;658 expectType<undefined>(ignoreStdioArrayResult.stdout);659 expectType<undefined>(ignoreStdioArrayResult.stdio[1]);660 expectType<string>(ignoreStdioArrayResult.stderr);661 expectType<string>(ignoreStdioArrayResult.stdio[2]);662 expectType<string>(ignoreStdioArrayResult.all);663 664+ const ignoreStdioArrayReadPromise = execa('unicorns', {stdio: ['ignore', 'ignore', 'pipe', new Uint8Array()], all: true});665+ expectType<Writable>(ignoreStdioArrayReadPromise.stdio[3]);666+667 const ignoreStdinPromise = execa('unicorns', {stdin: 'ignore'});668 expectType<null>(ignoreStdinPromise.stdin);669 670 const ignoreStdoutPromise = execa('unicorns', {stdout: 'ignore', all: true});671 expectType<Writable>(ignoreStdoutPromise.stdin);672+ expectType<Writable>(ignoreStdoutPromise.stdio[0]);673 expectType<null>(ignoreStdoutPromise.stdout);674+ expectType<null>(ignoreStdoutPromise.stdio[1]);675 expectType<Readable>(ignoreStdoutPromise.stderr);676+ expectType<Readable>(ignoreStdoutPromise.stdio[2]);677 expectType<Readable>(ignoreStdoutPromise.all);678+ expectError(ignoreStdoutPromise.stdio[3].destroy());679 const ignoreStdoutResult = await ignoreStdoutPromise;680 expectType<undefined>(ignoreStdoutResult.stdout);681 expectType<string>(ignoreStdoutResult.stderr);682 expectType<string>(ignoreStdoutResult.all);683 684 const ignoreStderrPromise = execa('unicorns', {stderr: 'ignore', all: true});685 expectType<Writable>(ignoreStderrPromise.stdin);686+ expectType<Writable>(ignoreStderrPromise.stdio[0]);687 expectType<Readable>(ignoreStderrPromise.stdout);688+ expectType<Readable>(ignoreStderrPromise.stdio[1]);689 expectType<null>(ignoreStderrPromise.stderr);690+ expectType<null>(ignoreStderrPromise.stdio[2]);691 expectType<Readable>(ignoreStderrPromise.all);692+ expectError(ignoreStderrPromise.stdio[3].destroy());693 const ignoreStderrResult = await ignoreStderrPromise;694 expectType<string>(ignoreStderrResult.stdout);695 expectType<undefined>(ignoreStderrResult.stderr);696 expectType<string>(ignoreStderrResult.all);697 698+ const ignoreStdioPromise = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ignore'], all: true});699+ expectType<Writable>(ignoreStdioPromise.stdin);700+ expectType<Writable>(ignoreStdioPromise.stdio[0]);701+ expectType<Readable>(ignoreStdioPromise.stdout);702+ expectType<Readable>(ignoreStdioPromise.stdio[1]);703+ expectType<Readable>(ignoreStdioPromise.stderr);704+ expectType<Readable>(ignoreStdioPromise.stdio[2]);705+ expectType<Readable>(ignoreStdioPromise.all);706+ expectType<null>(ignoreStdioPromise.stdio[3]);707+ const ignoreStdioResult = await ignoreStdioPromise;708+ expectType<string>(ignoreStdioResult.stdout);709+ expectType<string>(ignoreStdioResult.stderr);710+ expectType<string>(ignoreStdioResult.all);711+712 const inheritStdoutResult = await execa('unicorns', {stdout: 'inherit', all: true});713 expectType<undefined>(inheritStdoutResult.stdout);714 expectType<string>(inheritStdoutResult.stderr);715 expectType<string>(inheritStdoutResult.all);3149 unmodified linesmodified:readme.md+126 added-41 removed
319 unmodified lines320 321 Returns or throws a subprocess [`result`](#result). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available.322 323 The following features cannot be used:324-- Streams: [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin), [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr), [`subprocess.readable()`](#subprocessreadablereadableoptions), [`subprocess.writable()`](#subprocesswritablewritableoptions), [`subprocess.duplex()`](#subprocessduplexduplexoptions).325-- The [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [`stdio`](#optionsstdio) options cannot be [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async [transform](docs/transform.md), a [`Duplex`](docs/transform.md#duplextransform-streams), nor a web stream. Node.js streams can be passed but only if either they [have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr), or the `input` option is used.326-- Signal termination: [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`subprocess.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`cleanup`](#optionscleanup) option, [`cancelSignal`](#optionscancelsignal) option, [`forceKillAfterDelay`](#optionsforcekillafterdelay) option.324+- Streams: [`subprocess.stdin`](#subprocessstdin), [`subprocess.stdout`](#subprocessstdout), [`subprocess.stderr`](#subprocessstderr), [`subprocess.readable()`](#subprocessreadablereadableoptions), [`subprocess.writable()`](#subprocesswritablewritableoptions), [`subprocess.duplex()`](#subprocessduplexduplexoptions).325+- The [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [`stdio`](#optionsstdio) options cannot be [`'overlapped'`](#optionsstdout), an async iterable, an async [transform](docs/transform.md), a [`Duplex`](docs/transform.md#duplextransform-streams), nor a web stream. Node.js streams can be passed but only if either they [have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr), or the `input` option is used.326+- Signal termination: [`subprocess.kill()`](#subprocesskillerror), [`subprocess.pid`](#subprocesspid), [`cleanup`](#optionscleanup) option, [`cancelSignal`](#optionscancelsignal) option, [`forceKillAfterDelay`](#optionsforcekillafterdelay) option.327 - Piping multiple processes: [`subprocess.pipe()`](#subprocesspipefile-arguments-options).328 - [`subprocess.iterable()`](#subprocessiterablereadableoptions).329 - [`ipc`](#optionsipc) and [`serialization`](#optionsserialization) options.330 - [`result.all`](#resultall) is not interleaved.48 unmodified lines379 ### subprocess380 381 The return value of all [asynchronous methods](#methods) is both:382 - a `Promise` resolving or rejecting with a subprocess [`result`](#result).383-- a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following additional methods and properties.383+- a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following methods and properties.384 385-#### subprocess.all386-387-Type: `ReadableStream | undefined`388-389-Stream [combining/interleaving](#ensuring-all-output-is-interleaved) [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).390-391-This is `undefined` if either:392-- the [`all`](#optionsall) option is `false` (the default value)393-- both [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)394-385 #### subprocess.pipe(file, arguments?, options?)386 387 `file`: `string | URL`\388 `arguments`: `string[]`\69 unmodified lines458 When an error is passed as argument, it is set to the subprocess' [`error.cause`](#errorcause). The subprocess is then terminated with the default signal. This does not emit the [`error` event](https://nodejs.org/api/child_process.html#event-error).459 460 [More info.](https://nodejs.org/api/child_process.html#subprocesskillsignal)461 472-#### subprocess[Symbol.asyncIterator]()462+#### subprocess.pid463 464+_Type_: `number | undefined`465+466+Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).467+468+This is `undefined` if the subprocess failed to spawn.469+470+#### subprocess.send(message)471+472+`message`: `unknown`\473+_Returns_: `boolean`474+475+Send a `message` to the subprocess. The type of `message` depends on the [`serialization`](#optionsserialization) option.476+The subprocess receives it as a [`message` event](https://nodejs.org/api/process.html#event-message).477+478+This returns `true` on success.479+480+This requires the [`ipc`](#optionsipc) option to be `true`.481+482+[More info.](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback)483+484+#### subprocess.on('message', (message) => void)485+486+`message`: `unknown`487+488+Receives a `message` from the subprocess. The type of `message` depends on the [`serialization`](#optionsserialization) option.489+The subprocess sends it using [`process.send(message)`](https://nodejs.org/api/process.html#processsendmessage-sendhandle-options-callback).490+491+This requires the [`ipc`](#optionsipc) option to be `true`.492+493+[More info.](https://nodejs.org/api/child_process.html#event-message)494+495+#### subprocess.stdin496+497+Type: [`Writable | null`](https://nodejs.org/api/stream.html#class-streamwritable)498+499+The subprocess [`stdin`](#optionsstdin) as a stream.500+501+This is `null` if the [`stdin`](#optionsstdin) option is set to `'inherit'`, `'ignore'`, `Readable` or `integer`.502+503+This is intended for advanced cases. Please consider using the [`stdin`](#optionsstdin) option, [`input`](#optionsinput) option, [`inputFile`](#optionsinputfile) option, or [`subprocess.pipe()`](#subprocesspipefile-arguments-options) instead.504+505+#### subprocess.stdout506+507+Type: [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)508+509+The subprocess [`stdout`](#optionsstdout) as a stream.510+511+This is `null` if the [`stdout`](#optionsstdout) option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`.512+513+This is intended for advanced cases. Please consider using [`result.stdout`](#resultstdout), the [`stdout`](#optionsstdout) option, [`subprocess.iterable()`](#subprocessiterablereadableoptions), or [`subprocess.pipe()`](#subprocesspipefile-arguments-options) instead.514+515+#### subprocess.stderr516+517+Type: [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)518+519+The subprocess [`stderr`](#optionsstderr) as a stream.520+521+This is `null` if the [`stderr`](#optionsstdout) option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`.522+523+This is intended for advanced cases. Please consider using [`result.stderr`](#resultstderr), the [`stderr`](#optionsstderr) option, [`subprocess.iterable()`](#subprocessiterablereadableoptions), or [`subprocess.pipe()`](#subprocesspipefile-arguments-options) instead.524+525+#### subprocess.all526+527+Type: [`Readable | undefined`](https://nodejs.org/api/stream.html#class-streamreadable)528+529+Stream [combining/interleaving](#ensuring-all-output-is-interleaved) [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).530+531+This is `undefined` if either:532+- the [`all`](#optionsall) option is `false` (the default value).533+- both [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to `'inherit'`, `'ignore'`, `Writable` or `integer`.534+535+This is intended for advanced cases. Please consider using [`result.all`](#resultall), the [`stdout`](#optionsstdout)/[`stderr`](#optionsstderr) option, [`subprocess.iterable()`](#subprocessiterablereadableoptions), or [`subprocess.pipe()`](#subprocesspipefile-arguments-options) instead.536+537+#### subprocess.stdio538+539+Type: [`[Writable | null, Readable | null, Readable | null, ...Array<Writable | Readable | null>]`](https://nodejs.org/api/stream.html#class-streamreadable)540+541+The subprocess `stdin`, `stdout`, `stderr` and [other files descriptors](#optionsstdio) as an array of streams.542+543+Each array item is `null` if the corresponding [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option is set to `'inherit'`, `'ignore'`, `Stream` or `integer`.544+545+This is intended for advanced cases. Please consider using [`result.stdio`](#resultstdio), the [`stdio`](#optionsstdio) option, [`subprocess.iterable()`](#subprocessiterablereadableoptions) or [`subprocess.pipe()`](#subprocesspipefile-arguments-options) instead.546+547+#### subprocess\[Symbol.asyncIterator\]()548+549 _Returns_: `AsyncIterable`550 551 Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.552 12 unmodified lines565 _Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream566 567 Converts the subprocess to a readable stream.568 494-Unlike [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), the stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess [fails](#result). This means you do not need to `await` the subprocess' [promise](#subprocess). On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options), [`await pipeline(..., stream)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) or [`await text(stream)`](https://nodejs.org/api/webstreams.html#streamconsumerstextstream) which throw an exception when the stream errors.569+Unlike [`subprocess.stdout`](#subprocessstdout), the stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess [fails](#result). This means you do not need to `await` the subprocess' [promise](#subprocess). On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options), [`await pipeline(..., stream)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) or [`await text(stream)`](https://nodejs.org/api/webstreams.html#streamconsumerstextstream) which throw an exception when the stream errors.570 571 Before using this method, please first consider the [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr)/[`stdio`](#optionsstdio) options, [`subprocess.pipe()`](#subprocesspipefile-arguments-options) or [`subprocess.iterable()`](#subprocessiterablereadableoptions).572 573 #### subprocess.writable(writableOptions?)2 unmodified lines576 _Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream577 578 Converts the subprocess to a writable stream.579 505-Unlike [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin), the stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess [fails](#result). This means you do not need to `await` the subprocess' [promise](#subprocess). On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options) or [`await pipeline(stream, ...)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) which throw an exception when the stream errors.580+Unlike [`subprocess.stdin`](#subprocessstdin), the stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess [fails](#result). This means you do not need to `await` the subprocess' [promise](#subprocess). On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options) or [`await pipeline(stream, ...)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) which throw an exception when the stream errors.581 582 Before using this method, please first consider the [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr)/[`stdio`](#optionsstdio) options or [`subprocess.pipe()`](#subprocesspipefile-arguments-options).583 584 #### subprocess.duplex(duplexOptions?)93 unmodified lines678 Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`679 680 The output of the subprocess on `stdout`.681 607-This is `undefined` if the [`stdout`](#optionsstdout) option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the [`lines`](#optionslines) option is `true`, or if the `stdout` option is a [transform in object mode](docs/transform.md#object-mode).682+This is `undefined` if the [`stdout`](#optionsstdout) option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`. This is an array if the [`lines`](#optionslines) option is `true`, or if the `stdout` option is a [transform in object mode](docs/transform.md#object-mode).683 684 #### result.stderr685 686 Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`687 688 The output of the subprocess on `stderr`.689 615-This is `undefined` if the [`stderr`](#optionsstderr) option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the [`lines`](#optionslines) option is `true`, or if the `stderr` option is a [transform in object mode](docs/transform.md#object-mode).690+This is `undefined` if the [`stderr`](#optionsstderr) option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`. This is an array if the [`lines`](#optionslines) option is `true`, or if the `stderr` option is a [transform in object mode](docs/transform.md#object-mode).691 692 #### result.all693 694 Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`695 621-The output of the subprocess with `stdout` and `stderr` [interleaved](#ensuring-all-output-is-interleaved).696+The output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) [interleaved](#ensuring-all-output-is-interleaved).697 698 This is `undefined` if either:624-- the [`all`](#optionsall) option is `false` (the default value)625-- both [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)699+- the [`all`](#optionsall) option is `false` (the default value).700+- both [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to only `'inherit'`, `'ignore'`, `Writable` or `integer`.701 702 This is an array if the [`lines`](#optionslines) option is `true`, or if either the `stdout` or `stderr` option is a [transform in object mode](docs/transform.md#object-mode).703 704 #### result.stdio1 unmodified line706 Type: `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`707 708 The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).709 635-Items are `undefined` when their corresponding [`stdio`](#optionsstdio) option is set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). Items are arrays when their corresponding `stdio` option is a [transform in object mode](docs/transform.md#object-mode).710+Items are `undefined` when their corresponding [`stdio`](#optionsstdio) option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`. Items are arrays when their corresponding `stdio` option is a [transform in object mode](docs/transform.md#object-mode).711 712 #### result.failed713 714 Type: `boolean`232 unmodified lines947 Whether to return the subprocess' output using the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties.948 949 On failure, the [`error.stdout`](#resultstdout), [`error.stderr`](#resultstderr), [`error.all`](#resultall) and [`error.stdio`](#resultstdio) properties are used instead.950 876-When `buffer` is `false`, the output can still be read using the [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr), [`subprocess.stdio`](https://nodejs.org/api/child_process.html#subprocessstdio) and [`subprocess.all`](#subprocessall) streams. If the output is read, this should be done right away to avoid missing any data.951+When `buffer` is `false`, the output can still be read using the [`subprocess.stdout`](#subprocessstdout), [`subprocess.stderr`](#subprocessstderr), [`subprocess.stdio`](#subprocessstdio) and [`subprocess.all`](#subprocessall) streams. If the output is read, this should be done right away to avoid missing any data.952 953 #### options.input954 955 Type: `string | Uint8Array | stream.Readable`14 unmodified lines970 971 Type: `string | number | stream.Readable | ReadableStream | TransformStream | URL | {file: string} | Uint8Array | Iterable<string | Uint8Array | unknown> | AsyncIterable<string | Uint8Array | unknown> | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}` (or a tuple of those types)\972 Default: `inherit` with [`$`](#file-arguments-options), `pipe` otherwise973 899-[How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard input. This can be:900-- `'pipe'`: Sets [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin) stream.974+How to setup the subprocess' standard input. This can be:975+- `'pipe'`: Sets [`subprocess.stdin`](#subprocessstdin) stream.976 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.977 - `'ignore'`: Do not use `stdin`.978 - `'inherit'`: Re-use the current process' `stdin`.979 - an integer: Re-use a specific file descriptor from the current process.7 unmodified lines987 This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.988 989 This can also be a generator function, a [`Duplex`](docs/transform.md#duplextransform-streams) or a web [`TransformStream`](docs/transform.md#duplextransform-streams) to transform the input. [Learn more.](docs/transform.md)990 991+[More info.](https://nodejs.org/api/child_process.html#child_process_options_stdio)992+993 #### options.stdout994 995 Type: `string | number | stream.Writable | WritableStream | TransformStream | URL | {file: string} | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}` (or a tuple of those types)\996 Default: `pipe`997 921-[How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard output. This can be:922-- `'pipe'`: Sets [`result.stdout`](#resultstdout) (as a string or `Uint8Array`) and [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout) (as a stream).998+How to setup the subprocess' standard output. This can be:999+- `'pipe'`: Sets [`result.stdout`](#resultstdout) (as a string or `Uint8Array`) and [`subprocess.stdout`](#subprocessstdout) (as a stream).1000 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.1001 - `'ignore'`: Do not use `stdout`.1002 - `'inherit'`: Re-use the current process' `stdout`.1003 - an integer: Re-use a specific file descriptor from the current process.5 unmodified lines1009 This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.1010 1011 This can also be a generator function, a [`Duplex`](docs/transform.md#duplextransform-streams) or a web [`TransformStream`](docs/transform.md#duplextransform-streams) to transform the output. [Learn more.](docs/transform.md)1012 1013+[More info.](https://nodejs.org/api/child_process.html#child_process_options_stdio)1014+1015 #### options.stderr1016 1017 Type: `string | number | stream.Writable | WritableStream | TransformStream | URL | {file: string} | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}` (or a tuple of those types)\1018 Default: `pipe`1019 941-[How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard error. This can be:942-- `'pipe'`: Sets [`result.stderr`](#resultstderr) (as a string or `Uint8Array`) and [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr) (as a stream).1020+How to setup the subprocess' standard error. This can be:1021+- `'pipe'`: Sets [`result.stderr`](#resultstderr) (as a string or `Uint8Array`) and [`subprocess.stderr`](#subprocessstderr) (as a stream).1022 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.1023 - `'ignore'`: Do not use `stderr`.1024 - `'inherit'`: Re-use the current process' `stderr`.1025 - an integer: Re-use a specific file descriptor from the current process.5 unmodified lines1031 This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.1032 1033 This can also be a generator function, a [`Duplex`](docs/transform.md#duplextransform-streams) or a web [`TransformStream`](docs/transform.md#duplextransform-streams) to transform the output. [Learn more.](docs/transform.md)1034 1035+[More info.](https://nodejs.org/api/child_process.html#child_process_options_stdio)1036+1037 #### options.stdio1038 1039 Type: `string | Array<string | number | stream.Readable | stream.Writable | ReadableStream | WritableStream | TransformStream | URL | {file: string} | Uint8Array | Iterable<string> | Iterable<Uint8Array> | Iterable<unknown> | AsyncIterable<string | Uint8Array | unknown> | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}>` (or a tuple of those types)\1040 Default: `pipe`3 unmodified lines1044 A single string can be used as a shortcut. For example, `{stdio: 'pipe'}` is the same as `{stdin: 'pipe', stdout: 'pipe', stderr: 'pipe'}`.1045 1046 The array can have more than 3 items, to create additional file descriptors beyond `stdin`/`stdout`/`stderr`. For example, `{stdio: ['pipe', 'pipe', 'pipe', 'pipe']}` sets a fourth file descriptor.1047 1048+[More info.](https://nodejs.org/api/child_process.html#child_process_options_stdio)1049+1050 #### options.all1051 1052 Type: `boolean`\1053 Default: `false`52 unmodified lines1106 1107 Type: `boolean`\1108 Default: `true` if the [`node`](#optionsnode) option is enabled, `false` otherwise1109 1027-Enables exchanging messages with the subprocess using [`subprocess.send(value)`](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback) and [`subprocess.on('message', (value) => {})`](https://nodejs.org/api/child_process.html#event-message).1110+Enables exchanging messages with the subprocess using [`subprocess.send(message)`](#subprocesssendmessage) and [`subprocess.on('message', (message) => {})`](#subprocessonmessage-message--void).1111 1112 #### options.serialization1113 1114 Type: `string`\1115 Default: `'advanced'`1116 1117 Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option:1035- - `json`: Uses `JSON.stringify()` and `JSON.parse()`.1036- - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)1118+- `json`: Uses `JSON.stringify()` and `JSON.parse()`.1119+- `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)1120 1121 [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)1122 1123 #### options.detached1124 1125 Type: `boolean`\1126 Default: `false`1127 1045-Prepare subprocess to run independently of the current process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).1128+Prepare subprocess to run independently of the current process. Specific behavior depends on the platform.1129 1130+[More info.](https://nodejs.org/api/child_process.html#child_process_options_detached).1131+1132 #### options.cleanup1133 1134 Type: `boolean`\1135 Default: `true`1136 1137 Kill the subprocess when the current process exits unless either:1053- - the subprocess is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)1054- - the current process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit1138+- the subprocess is [`detached`](#optionsdetached).1139+- the current process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit.1140 1141 #### options.timeout1142 1143 Type: `number`\19 unmodified lines1163 The grace period is 5 seconds by default. This feature can be disabled with `false`.1164 1165 This works when the subprocess is terminated by either:1166 - the [`cancelSignal`](#optionscancelsignal), [`timeout`](#optionstimeout), [`maxBuffer`](#optionsmaxbuffer) or [`cleanup`](#optionscleanup) option1082-- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with no arguments1167+- calling [`subprocess.kill()`](#subprocesskillsignal-error) with no arguments1168 1169 This does not work when the subprocess is terminated by either:1085-- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with an argument1170+- calling [`subprocess.kill()`](#subprocesskillsignal-error) with an argument1171 - calling [`process.kill(subprocess.pid)`](https://nodejs.org/api/process.html#processkillpid-signal)1172 - sending a termination signal from another process1173 1174 Also, this does not work on Windows, because Windows [doesn't support signals](https://nodejs.org/api/process.html#process_signal_events): `SIGKILL` and `SIGTERM` both terminate the subprocess immediately. Other packages (such as [`taskkill`](https://github.com/sindresorhus/taskkill)) can be used to achieve fail-safe termination on Windows.4 unmodified lines1179 Default: `SIGTERM`1180 1181 Signal used to terminate the subprocess when:1182 - using the [`cancelSignal`](#optionscancelsignal), [`timeout`](#optionstimeout), [`maxBuffer`](#optionsmaxbuffer) or [`cleanup`](#optionscleanup) option1098-- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with no arguments1183+- calling [`subprocess.kill()`](#subprocesskillsignal-error) with no arguments1184 1185 This can be either a name (like `"SIGTERM"`) or a number (like `9`).1186 1187 #### options.argv050 unmodified lines1238 TypeError [ERR_INVALID_ARG_VALUE]: The argument 'stdio' is invalid.1239 ```1240 1241 This limitation can be worked around by passing either:1157- - a web stream ([`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) or [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream))1158- - `[nodeStream, 'pipe']` instead of `nodeStream`1242+- a web stream ([`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) or [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream))1243+- `[nodeStream, 'pipe']` instead of `nodeStream`1244 1245 ```diff1246 - await execa(..., {stdout: nodeStream});1247 + await execa(..., {stdout: [nodeStream, 'pipe']});90 unmodified lines