Fix documentation and types mistakes
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 a2eda67 · Browse files · 19 files·+107 added−52 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
19 files+107 added−52 removed
- other:+107 added−52 removed
Provenance
- Commit
74b854a- Tree
25a47eb- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
a2eda67
19 files changed+107 added−52 removed
modified:docs/api.md+13 added-9 removed
393 unmodified lines394 _Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)395 396 The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.397 398-This is `null` if the [`stdout`](#optionsstdout) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.398+This is `null` if the [`stdout`](#optionsstdout) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output).399 400 [More info.](streams.md#manual-streaming)401 402 ### subprocess.stderr1 unmodified line404 _Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)405 406 The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.407 408-This is `null` if the [`stderr`](#optionsstdout) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.408+This is `null` if the [`stderr`](#optionsstderr) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output).409 410 [More info.](streams.md#manual-streaming)411 412 ### subprocess.all13 unmodified lines426 _Type:_ [`[Writable | null, Readable | null, Readable | null, ...Array<Writable | Readable | null>]`](https://nodejs.org/api/stream.html#class-streamreadable)427 428 The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.429 430-Each array item is `null` if the corresponding [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Stream`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.430+Each array item is `null` if the corresponding [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Stream`](streams.md#output) or [`integer`](output.md#terminal-output).431 432+With the [`ipc`](#optionsipc) option, the last item is the subprocess' IPC channel, which is always `null`.433+434 [More info.](streams.md#manual-streaming)435 436 ### subprocess.readable(readableOptions?)437 153 unmodified lines591 The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).592 593 Items are `undefined` when their corresponding [`stdio`](#optionsstdio) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.594 595+With the [`ipc`](#optionsipc) option, the last item is the subprocess' IPC channel, which is always `undefined`.596+597 Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).598 599 [More info.](output.md#additional-file-descriptors)600 429 unmodified lines1030 Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).1031 1032 By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).1033 1030-With [synchronous methods](execution.md#synchronous-execution), this cannot be enforced per file descriptor while the subprocess runs, since `spawnSync()` only accepts a single value, which limits the total output of all file descriptors. The `maxBuffer.stdout` value is used for it. The other file descriptors' own values are enforced from the output, once the subprocess ended, and cannot be higher than `maxBuffer.stdout`.1034+With [synchronous methods](execution.md#synchronous-execution), this cannot be enforced per file descriptor while the subprocess runs, since `spawnSync()` only accepts a single value, which limits the total output of all file descriptors. The `maxBuffer.stdout` value is used for it. The other file descriptors' own values are enforced from the output, once the subprocess ended, and cannot be higher than `maxBuffer.stdout`. Also, with synchronous methods, this is measured in bytes instead of [characters or lines](output.md#big-output), for the same reason.1035 1036 When reached, [`error.isMaxBuffer`](#errorismaxbuffer) becomes `true`.1037 1038 [More info.](output.md#big-output)67 unmodified lines1106 1107 _Type:_ `number`\1108 _Default:_ `0`1109 1106-If `timeout` is greater than `0`, the subprocess will be [terminated](#optionskillsignal) if it runs for longer than that amount of milliseconds. The maximum value is `2147483647` (about 24.8 days).1110+If `timeout` is greater than `0`, the subprocess will be [terminated](#optionskillsignal) if it runs for longer than that amount of milliseconds. It must be a non-negative integer, up to `2147483647` (about 24.8 days).1111 1112 On timeout, [`error.timedOut`](#errortimedout) becomes `true`.1113 1114 [More info.](termination.md#timeout)22 unmodified lines1137 [More info.](termination.md#graceful-termination)1138 1139 ### options.forceKillAfterDelay1140 1137-_Type:_ `number | false`\1141+_Type:_ `number | boolean`\1142 _Default:_ `5000`1143 1140-If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL). The maximum delay is `2147483647` milliseconds (about 24.8 days).1144+If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL). The delay must be a non-negative integer, up to `2147483647` milliseconds (about 24.8 days). When `true`, the default `5000` is used. When `false`, the subprocess is not forcefully exited.1145 1146 When this happens, [`error.isForcefullyTerminated`](#errorisforcefullyterminated) becomes `true`.1147 1148 [More info.](termination.md#forceful-termination)118 unmodified lines1267 - `'command'`: the [`result.escapedCommand`](#resultescapedcommand)1268 - `'output'`: one line from [`result.stdout`](#resultstdout) or [`result.stderr`](#resultstderr)1269 - `'ipc'`: one IPC message from [`result.ipcOutput`](#resultipcoutput)1270 - `'error'`: the [`error.shortMessage`](#errorshortmessage)1267-- `'duration'`: the [`result.durationMs`](#resultdurationms)1271+- `'duration'`: the [`result.durationMs`](#resultdurationms), formatted as `(done in 29ms)`1272 1273 #### verboseObject.escapedCommand1274 1275 _Type_: `string`33 unmodified lines1309 #### verboseObject.piped1310 1311 _Type_: `boolean`1312 1309-Whether another subprocess is [piped](pipe.md) into this subprocess. This is `false` when [`result.pipedFrom`](#resultfailed) is empty.1313+Whether this subprocess is the destination of another subprocess' [`pipe()`](#subprocesspipefile-arguments-options) method. This is `true` when it was spawned using the [template string](pipe.md#template-string-syntax) or [array](pipe.md#array-syntax) syntax, `false` otherwise.1314 1315 ## Transform options1316 1317 A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.52 unmodified linesmodified:docs/bash.md+1 added-1 removed
294 unmodified lines295 ```js296 // Execa297 import {$ as $_} from 'execa';298 299-const $ = $_({verbose: true});299+const $ = $_({verbose: 'short'});300 301 await $`npm run init`;302 await $`npm run build`;303 await $`npm run test`;992 unmodified linesmodified:docs/input.md+1 added-1 removed
66 unmodified lines6768697071717273747580 unmodified lines66 unmodified lines## Ignore input
```jsconst subprocess = execa({stdin: 'ignore'})`npm run scaffold`;console.log(subprocess.stdin); // undefinedconsole.log(subprocess.stdin); // nullawait subprocess;```
## File input80 unmodified linesmodified:docs/ipc.md+1 added-1 removed
172 unmodified lines173 ```174 175 ## Message type176 177-By default, messages are serialized using [`structuredClone()`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). This supports most types including objects, arrays, `Error`, `Date`, `RegExp`, `Map`, `Set`, `bigint`, `Uint8Array`, and circular references. This throws when passing functions, symbols or promises (including inside an object or array).177+By default, messages are serialized using [`structuredClone()`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). This supports most types including objects, arrays, `Error`, `Date`, `RegExp`, `Map`, `Set`, `Uint8Array`, and circular references. This throws when passing functions, symbols or promises (including inside an object or array).178 179 To limit messages to JSON instead, the [`serialization`](api.md#optionsserialization) option can be set to `'json'`.180 181 ```js49 unmodified linesmodified:docs/lines.md+1 added-1 removed
34 unmodified lines35 36 The iteration waits for the subprocess to end (even when using [`break`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/break) or [`return`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return)). It throws if the subprocess [fails](api.md#result). This means you do not need to `await` the subprocess' [promise](execution.md#result).37 38 ```js39-for await (const line of execa`npm run build`.iterable())) {39+for await (const line of execa`npm run build`.iterable()) {40 /* ... */41 }42 ```43 101 unmodified linesmodified:docs/output.md+1 added
177 unmodified lines178 - If the [`encoding`](binary.md#encoding) option is `'buffer'`: in bytes.179 - If the [`lines`](lines.md#simple-splitting) option is `true`: in lines.180 - If a [transform in object mode](transform.md#object-mode) is used: in objects.181 - With [`error.ipcOutput`](ipc.md#retrieve-all-messages): in messages.182+- With [synchronous methods](execution.md#synchronous-execution): in bytes, since `spawnSync()`'s limit is enforced by Node.js itself before the output is decoded or split into lines.183 184 ```js185 try {186 await execa({maxBuffer: 1_000_000})`npm run build`;22 unmodified linesmodified:docs/streams.md+1 added-1 removed
66 unmodified lines67 ```68 69 ## Manual streaming70 71-[`subprocess.stdin`](api.md#subprocessstdin) is a Node.js [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) stream and [`subprocess.stdout`](api.md#subprocessstdout)/[`subprocess.stderr`](api.md#subprocessstderr)/[`subprocess.all`](api.md#subprocessall) are Node.js [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) streams.71+[`subprocess.stdin`](api.md#subprocessstdin) is a Node.js [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) stream and [`subprocess.stdout`](api.md#subprocessstdout)/[`subprocess.stderr`](api.md#subprocessstderr)/[`subprocess.all`](api.md#subprocessall) are Node.js [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) streams.72 73 They can be used to stream input/output manually. This is intended for advanced situations. In most cases, the following simpler solutions can be used instead:74 - [`result.stdout`](output.md#stdout-and-stderr), [`result.stderr`](output.md#stdout-and-stderr) or [`result.stdio`](output.md#additional-file-descriptors).75 - The [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout), [`stderr`](api.md#optionsstderr) or [`stdio`](api.md#optionsstdio) options.64 unmodified linesmodified:docs/transform.md+1 added-1 removed
53 unmodified lines54 };55 56 const {stdout} = await execa({stdout: {transform, objectMode: true}})`node jsonlines-output.js`;57 for (const data of stdout) {58- console.log(stdout); // {...object}58+ console.log(data); // {...object}59 }60 ```61 62 [`stdin`](api.md#optionsstdin) can also use `objectMode: true`.95 unmodified linesmodified:test-d/return/ignore-option.test-d.ts-4 removed
18 unmodified lines19 expectType<null>(ignoreAnySubprocess.stdio[1]);20 expectType<null>(ignoreAnySubprocess.stderr);21 expectType<null>(ignoreAnySubprocess.stdio[2]);22 expectType<undefined>(ignoreAnySubprocess.all);23-expectError(ignoreAnySubprocess.stdio[3].destroy());23 24 const ignoreAnyResult = await ignoreAnySubprocess;25 expectType<undefined>(ignoreAnyResult.stdout);26 expectType<undefined>(ignoreAnyResult.stdio[1]);8 unmodified lines35 expectType<null>(ignoreAllSubprocess.stdio[1]);36 expectType<null>(ignoreAllSubprocess.stderr);37 expectType<null>(ignoreAllSubprocess.stdio[2]);38 expectType<undefined>(ignoreAllSubprocess.all);40-expectError(ignoreAllSubprocess.stdio[3].destroy());39 40 const ignoreAllResult = await ignoreAllSubprocess;41 expectType<undefined>(ignoreAllResult.stdout);42 expectType<undefined>(ignoreAllResult.stdio[1]);30 unmodified lines73 expectType<null>(ignoreStdoutSubprocess.stdio[1]);74 expectType<Readable>(ignoreStdoutSubprocess.stderr);75 expectType<Readable>(ignoreStdoutSubprocess.stdio[2]);76 expectType<Readable>(ignoreStdoutSubprocess.all);79-expectError(ignoreStdoutSubprocess.stdio[3].destroy());77 78 const ignoreStdoutResult = await ignoreStdoutSubprocess;79 expectType<undefined>(ignoreStdoutResult.stdout);80 expectType<string>(ignoreStdoutResult.stderr);6 unmodified lines87 expectType<Readable>(ignoreStderrSubprocess.stdio[1]);88 expectType<null>(ignoreStderrSubprocess.stderr);89 expectType<null>(ignoreStderrSubprocess.stdio[2]);90 expectType<Readable>(ignoreStderrSubprocess.all);94-expectError(ignoreStderrSubprocess.stdio[3].destroy());91 92 const ignoreStderrResult = await ignoreStderrSubprocess;93 expectType<string>(ignoreStderrResult.stdout);94 expectType<undefined>(ignoreStderrResult.stderr);55 unmodified linesmodified:test-d/return/no-buffer-main.test-d.ts-1 removed
13 unmodified lines14 expectType<Readable>(noBufferSubprocess.stdio[1]);15 expectType<Readable>(noBufferSubprocess.stderr);16 expectType<Readable>(noBufferSubprocess.stdio[2]);17 expectType<Readable>(noBufferSubprocess.all);18-expectError(noBufferSubprocess.stdio[3].destroy());18 19 const noBufferResult = await noBufferSubprocess;20 expectType<undefined>(noBufferResult.stdout);21 expectType<undefined>(noBufferResult.stdio[1]);23 unmodified linesmodified:test-d/return/result-main.test-d.ts+2 added-2 removed
33 unmodified lines34 expectType<keyof SignalConstants | undefined>(unicornsResult.signal);35 expectType<string | undefined>(unicornsResult.signalDescription);36 expectType<string>(unicornsResult.cwd);37 expectType<number>(unicornsResult.durationMs);38-expectType<Result[]>(unicornsResult.pipedFrom);38+expectType<Array<Result | ExecaError>>(unicornsResult.pipedFrom);39 40 const unicornsResultSync = execaSync('unicorns', {all: true});41 expectAssignable<SyncResult>(unicornsResultSync);42 expectType<string>(unicornsResultSync.command);32 unmodified lines75 expectType<string>(error.shortMessage);76 expectType<string>(error.originalMessage);77 expectType<string | undefined>(error.code);78 expectType<unknown>(error.cause);79- expectType<Result[]>(error.pipedFrom);79+ expectType<Array<Result | ExecaError>>(error.pipedFrom);80 }81 82 const errorSync = new Error('.');83 if (errorSync instanceof ExecaSyncError) {21 unmodified linesmodified:test-d/return/result-stdio.test-d.ts+18 added
152 unmodified lines153 expectType<undefined>(undefinedFd3Result.stdio[3]);154 155 const undefinedArrayFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [undefined] as const]});156 expectType<undefined>(undefinedArrayFd3Result.stdio[3]);157+158+const ipcResult = await execa('unicorns', {ipc: true});159+expectType<[undefined, string, string, undefined]>(ipcResult.stdio);160+161+const ipcInputResult = await execa('unicorns', {ipcInput: ''});162+expectType<[undefined, string, string, undefined]>(ipcInputResult.stdio);163+164+const gracefulCancelResult = await execa('unicorns', {cancelSignal: AbortSignal.abort(), gracefulCancel: true});165+expectType<[undefined, string, string, undefined]>(gracefulCancelResult.stdio);166+167+const fd3IpcResult = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], ipc: true});168+expectType<[undefined, string, string, string, undefined]>(fd3IpcResult.stdio);169+170+const noIpcResult = await execa('unicorns');171+expectType<[undefined, string, string]>(noIpcResult.stdio);172+173+const noIpcResultSync = execaSync('unicorns');174+expectType<[undefined, string, string]>(noIpcResultSync.stdio);modified:test-d/subprocess/stdio.test-d.ts+28 added-3 removed
13 unmodified lines14 expectType<Readable>(bufferSubprocess.stdio[1]);15 expectType<Readable>(bufferSubprocess.stderr);16 expectType<Readable>(bufferSubprocess.stdio[2]);17 expectType<Readable>(bufferSubprocess.all);18-expectError(bufferSubprocess.stdio[3].destroy());18+expectType<Writable>(bufferSubprocess.stdio[0]);19 20 const hexSubprocess = execa('unicorns', {encoding: 'hex', all: true});21 expectType<Writable>(hexSubprocess.stdin);22 expectType<Writable>(hexSubprocess.stdio[0]);1 unmodified line24 expectType<Readable>(hexSubprocess.stdio[1]);25 expectType<Readable>(hexSubprocess.stderr);26 expectType<Readable>(hexSubprocess.stdio[2]);27 expectType<Readable>(hexSubprocess.all);28-expectError(hexSubprocess.stdio[3].destroy());28+expectType<Writable>(hexSubprocess.stdio[0]);29 30 const multipleStdinSubprocess = execa('unicorns', {stdin: ['inherit', 'pipe']});31 expectType<Writable>(multipleStdinSubprocess.stdin);32 4 unmodified lines37 expectType<Readable>(multipleStdoutSubprocess.stdio[1]);38 expectType<Readable>(multipleStdoutSubprocess.stderr);39 expectType<Readable>(multipleStdoutSubprocess.stdio[2]);40 expectType<Readable>(multipleStdoutSubprocess.all);41-expectError(multipleStdoutSubprocess.stdio[3].destroy());41+expectType<Writable>(multipleStdoutSubprocess.stdio[0]);42 43 const inputPipeSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input: true}]});44 expectType<Writable>(inputPipeSubprocess.stdio[3]);45 27 unmodified lines73 74 const stderrInputPipeSubprocess = execa('unicorns', {stderr: {value: 'pipe', input: true}});75 expectType<Readable>(stderrInputPipeSubprocess.stderr);76 expectType<Readable>(stderrInputPipeSubprocess.stdio[2]);77+78+const noIpcSubprocess = execa('unicorns');79+expectType<Writable>(noIpcSubprocess.stdio[0]);80+expectType<Readable>(noIpcSubprocess.stdio[1]);81+expectType<Readable>(noIpcSubprocess.stdio[2]);82+83+const ipcSubprocess = execa('unicorns', {ipc: true});84+expectType<Writable>(ipcSubprocess.stdio[0]);85+expectType<Readable>(ipcSubprocess.stdio[1]);86+expectType<Readable>(ipcSubprocess.stdio[2]);87+expectType<null>(ipcSubprocess.stdio[3]);88+89+const ipcInputSubprocess = execa('unicorns', {ipcInput: ''});90+expectType<null>(ipcInputSubprocess.stdio[3]);91+92+const fd3IpcSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], ipc: true});93+expectType<Readable>(fd3IpcSubprocess.stdio[3]);94+expectType<null>(fd3IpcSubprocess.stdio[4]);95+96+const fd5IpcSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe'], ipc: true});97+expectType<Readable>(fd5IpcSubprocess.stdio[5]);98+expectType<null>(fd5IpcSubprocess.stdio[6]);99+expectType<Readable | Writable | null>(fd5IpcSubprocess.stdio[7]);100+101+expectType<Readable | Writable | null>(noIpcSubprocess.stdio[3]);modified:types/arguments/options.d.ts+3 added-3 removed
190 unmodified lines191 Largest amount of data allowed on `stdout`, `stderr` and `stdio`.192 193 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.194 195- With synchronous methods, this cannot be enforced per file descriptor while the subprocess runs, since `spawnSync()` only accepts a single value, which limits the total output of all file descriptors. The `maxBuffer.stdout` value is used for it. The other file descriptors' own values are enforced from the output, once the subprocess ended, and cannot be higher than `maxBuffer.stdout`.195+ With synchronous methods, this cannot be enforced per file descriptor while the subprocess runs, since `spawnSync()` only accepts a single value, which limits the total output of all file descriptors. The `maxBuffer.stdout` value is used for it. The other file descriptors' own values are enforced from the output, once the subprocess ended, and cannot be higher than `maxBuffer.stdout`. Also, with synchronous methods, this is measured in bytes instead of characters or lines, for the same reason.196 197 When reached, `error.isMaxBuffer` becomes `true`.198 199 @default 100_000_00052 unmodified lines252 */253 readonly reject?: boolean;254 255 /**256- If `timeout` is greater than `0`, the subprocess will be terminated if it runs for longer than that amount of milliseconds. The maximum value is `2147483647` (about 24.8 days).256+ If `timeout` is greater than `0`, the subprocess will be terminated if it runs for longer than that amount of milliseconds. It must be a non-negative integer, up to `2147483647` (about 24.8 days).257 258 On timeout, `error.timedOut` becomes `true`.259 260 @default 040 unmodified lines301 */302 readonly gracefulCancel?: Unless<IsSync, boolean>;303 304 /**305- If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL). The maximum delay is `2147483647` milliseconds (about 24.8 days).305+ If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL). The delay must be a non-negative integer, up to `2147483647` milliseconds (about 24.8 days). When `true`, the default `5000` is used. When `false`, the subprocess is not forcefully exited.306 307 When this happens, `error.isForcefullyTerminated` becomes `true`.308 309 @default 5000120 unmodified linesmodified:types/return/result-stdio.d.ts+14 added-10 removed
1 import type {StdioOptionNormalizedArray} from '../stdio/array.js';2-import type {CommonOptions} from '../arguments/options.js';2+import type {HasIpc} from '../ipc.js';3+import type {CommonOptions, Options, StricterOptions} from '../arguments/options.js';4 import type {ResultStdioNotAll} from './result-stdout.js';5 6 // `result.stdio`6-export type ResultStdioArray<OptionsType extends CommonOptions> =7- MapResultStdio<StdioOptionNormalizedArray<OptionsType>, OptionsType>;7+// With the `ipc` option, the subprocess' IPC channel adds one last file descriptor, which has no output8+export type ResultStdioArray<OptionsType extends CommonOptions> = MapResultStdio<StdioOptionNormalizedArray<OptionsType>, OptionsType>;9 10 type MapResultStdio<10- StdioOptionsArrayType,11+ StdioOptionsArrayType extends readonly unknown[],12 OptionsType extends CommonOptions,13+> = [12-> = {13- -readonly [FdNumber in keyof StdioOptionsArrayType]: ResultStdioNotAll<14- FdNumber extends string ? FdNumber : string,15- OptionsType16- >17-};14+ ...{15+ -readonly [FdNumber in keyof StdioOptionsArrayType]: ResultStdioNotAll<16+ FdNumber extends string ? FdNumber : string,17+ OptionsType18+ >19+ },20+ ...(HasIpc<StricterOptions<OptionsType, Options>> extends true ? [undefined] : []),21+];22 23 export {};modified:types/return/result.d.ts+4 added-2 removed
1 import type {SignalConstants} from 'node:os';2 import type {Unless} from '../utils.js';3 import type {CommonOptions, Options, SyncOptions} from '../arguments/options.js';4-import type {ErrorProperties} from './final-error.js';4+import type {ErrorProperties, ExecaError} from './final-error.js';5 import type {ResultAll} from './result-all.js';6 import type {ResultStdioArray} from './result-stdio.js';7 import type {ResultStdioNotAll} from './result-stdout.js';8 import type {ResultIpcOutput} from './result-ipc.js';35 unmodified lines44 The output of the subprocess on `stdin`, `stdout`, `stderr` and other file descriptors.45 46 Items are `undefined` when their corresponding `stdio` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.47 48+ With the `ipc` option, the last item is the subprocess' IPC channel, which is always `undefined`.49+50 Items are arrays when their corresponding `stdio` option is a transform in object mode.51 */52 stdio: ResultStdioArray<OptionsType>;53 8 unmodified lines62 Results of the other subprocesses that were piped into this subprocess.63 64 This array is initially empty and is populated each time the `subprocess.pipe()` method resolves.65 */64- pipedFrom: Unless<IsSync, Result[], []>;66+ pipedFrom: Unless<IsSync, Array<Result | ExecaError>, []>;67 68 /**69 The file and arguments that were run.70 */135 unmodified linesmodified:types/subprocess/stdio.d.ts+11 added-7 removed
1+import type {Readable, Writable} from 'node:stream';2 import type {StdioOptionNormalizedArray} from '../stdio/array.js';3+import type {HasIpc} from '../ipc.js';4 import type {Options} from '../arguments/options.js';5 import type {SubprocessStdioStream} from './stdout.js';6 7 // `subprocess.stdio`8 export type SubprocessStdioArray<OptionsType extends Options> = MapStdioStreams<StdioOptionNormalizedArray<OptionsType>, OptionsType>;9 8-// We cannot use mapped types because it must be compatible with Node.js `ChildProcess["stdio"]` which uses a tuple with exactly 5 items10+// File descriptors beyond `stderr` are only present when the `stdio` option is an array with more items.11+// The subprocess' IPC channel, if any, is set as the last file descriptor by Node.js itself.12+// Since any `Subprocess` can be passed where the default one is expected, the list is kept open-ended.13 type MapStdioStreams<10- StdioOptionsArrayType,14+ StdioOptionsArrayType extends readonly unknown[],15 OptionsType extends Options,16 > = [13- SubprocessStdioStream<'0', OptionsType>,14- SubprocessStdioStream<'1', OptionsType>,15- SubprocessStdioStream<'2', OptionsType>,16- '3' extends keyof StdioOptionsArrayType ? SubprocessStdioStream<'3', OptionsType> : never,17- '4' extends keyof StdioOptionsArrayType ? SubprocessStdioStream<'4', OptionsType> : never,17+ ...{18+ -readonly [FdNumber in keyof StdioOptionsArrayType]: SubprocessStdioStream<FdNumber extends string ? FdNumber : string, OptionsType>19+ },20+ ...(HasIpc<OptionsType> extends true ? [null] : []),21+ ...Array<Readable | Writable | null>,22 ];23 24 export {};modified:types/subprocess/subprocess.d.ts+5 added-3 removed
70 unmodified lines71 72 /**73 The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.74 75- This is `null` if the `stdout` option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.75+ This is `null` if the `stdout` option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`.76 */77 stdout: SubprocessStdioStream<'1', OptionsType>;78 79 /**80 The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.81 82- This is `null` if the `stderr` option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.82+ This is `null` if the `stderr` option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`.83 */84 stderr: SubprocessStdioStream<'2', OptionsType>;85 86 /**87 The subprocess `stdin`, `stdout`, `stderr` and other files descriptors as an array of streams.88 89- Each array item is `null` if the corresponding `stdin`, `stdout`, `stderr` or `stdio` option is set to `'inherit'`, `'ignore'`, `Stream` or `integer`, or if the `buffer` option is `false`.89+ Each array item is `null` if the corresponding `stdin`, `stdout`, `stderr` or `stdio` option is set to `'inherit'`, `'ignore'`, `Stream` or `integer`.90+91+ With the `ipc` option, the last item is the subprocess' IPC channel, which is always `null`.92 */93 stdio: SubprocessStdioArray<OptionsType>;94 95 /**55 unmodified linesmodified:types/verbose.d.ts+2 added-2 removed
26 unmodified lines27 - `'command'`: the `result.escapedCommand`28 - `'output'`: one line from `result.stdout` or `result.stderr`29 - `'ipc'`: one IPC message from `result.ipcOutput`30 - `'error'`: the `error.shortMessage`31- - `'duration'`: the `result.durationMs`31+ - `'duration'`: the `result.durationMs`, formatted as `(done in 29ms)`32 */33 message: string;34 35 /**15 unmodified lines51 */52 timestamp: Date;53 54 /**55- Whether another subprocess is piped into this subprocess. This is `false` when `result.pipedFrom` is empty.55+ Whether this subprocess is the destination of another subprocess' `pipe()` method. This is `true` when it was spawned using the template string or array syntax of `pipe()`, `false` otherwise.56 */57 piped: boolean;58 };59 41 unmodified lines