Skip to content
Myr

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

19 files+107 added−52 removed

modified:docs/api.md+13 added-9 removed
393 unmodified lines
394_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)395396The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.397398This 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`.398This 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).399400[More info.](streams.md#manual-streaming)401402### subprocess.stderr
1 unmodified line
404_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)405406The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.407408This 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`.408This 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).409410[More info.](streams.md#manual-streaming)411412### subprocess.all
13 unmodified lines
426_Type:_ [`[Writable | null, Readable | null, Readable | null, ...Array<Writable | Readable | null>]`](https://nodejs.org/api/stream.html#class-streamreadable)427428The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.429430Each 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`.430Each 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).431432With the [`ipc`](#optionsipc) option, the last item is the subprocess' IPC channel, which is always `null`.433434[More info.](streams.md#manual-streaming)435436### subprocess.readable(readableOptions?)437
153 unmodified lines
591The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).592593Items 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`.594595With the [`ipc`](#optionsipc) option, the last item is the subprocess' IPC channel, which is always `undefined`.596597Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).598599[More info.](output.md#additional-file-descriptors)600
429 unmodified lines
1030Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).10311032By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10331030With [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`.1034With [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.10351036When reached, [`error.isMaxBuffer`](#errorismaxbuffer) becomes `true`.10371038[More info.](output.md#big-output)
67 unmodified lines
11061107_Type:_ `number`\1108_Default:_ `0`11091106If `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).1110If `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).11111112On timeout, [`error.timedOut`](#errortimedout) becomes `true`.11131114[More info.](termination.md#timeout)
22 unmodified lines
1137[More info.](termination.md#graceful-termination)11381139### options.forceKillAfterDelay11401137_Type:_ `number | false`\1141_Type:_ `number | boolean`\1142_Default:_ `5000`11431140If 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).1144If 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.11451146When this happens, [`error.isForcefullyTerminated`](#errorisforcefullyterminated) becomes `true`.11471148[More info.](termination.md#forceful-termination)
118 unmodified lines
1267- `'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)`12721273#### verboseObject.escapedCommand12741275_Type_: `string`
33 unmodified lines
1309#### verboseObject.piped13101311_Type_: `boolean`13121309Whether another subprocess is [piped](pipe.md) into this subprocess. This is `false` when [`result.pipedFrom`](#resultfailed) is empty.1313Whether 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.13141315## Transform options13161317A 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 lines
modified:docs/bash.md+1 added-1 removed
294 unmodified lines
295```js296// Execa297import {$ as $_} from 'execa';298299const $ = $_({verbose: true});299const $ = $_({verbose: 'short'});300301await $`npm run init`;302await $`npm run build`;303await $`npm run test`;
992 unmodified lines
modified:docs/input.md+1 added-1 removed
modified:docs/ipc.md+1 added-1 removed
172 unmodified lines
173```174175## Message type176177By 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).177By 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).178179To limit messages to JSON instead, the [`serialization`](api.md#optionsserialization) option can be set to `'json'`.180181```js
49 unmodified lines
modified:docs/lines.md+1 added-1 removed
34 unmodified lines
3536The 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).3738```js39for await (const line of execa`npm run build`.iterable())) {39for await (const line of execa`npm run build`.iterable()) {40 /* ... */41}42```43
101 unmodified lines
modified:docs/output.md+1 added
177 unmodified lines
178- 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.183184```js185try {186 await execa({maxBuffer: 1_000_000})`npm run build`;
22 unmodified lines
modified:docs/streams.md+1 added-1 removed
66 unmodified lines
67```6869## Manual streaming7071[`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.7273They 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 lines
modified:docs/transform.md+1 added-1 removed
53 unmodified lines
54};5556const {stdout} = await execa({stdout: {transform, objectMode: true}})`node jsonlines-output.js`;57for (const data of stdout) {58 console.log(stdout); // {...object}58 console.log(data); // {...object}59}60```6162[`stdin`](api.md#optionsstdin) can also use `objectMode: true`.
95 unmodified lines
modified:test-d/return/ignore-option.test-d.ts-4 removed
18 unmodified lines
19expectType<null>(ignoreAnySubprocess.stdio[1]);20expectType<null>(ignoreAnySubprocess.stderr);21expectType<null>(ignoreAnySubprocess.stdio[2]);22expectType<undefined>(ignoreAnySubprocess.all);23expectError(ignoreAnySubprocess.stdio[3].destroy());2324const ignoreAnyResult = await ignoreAnySubprocess;25expectType<undefined>(ignoreAnyResult.stdout);26expectType<undefined>(ignoreAnyResult.stdio[1]);
8 unmodified lines
35expectType<null>(ignoreAllSubprocess.stdio[1]);36expectType<null>(ignoreAllSubprocess.stderr);37expectType<null>(ignoreAllSubprocess.stdio[2]);38expectType<undefined>(ignoreAllSubprocess.all);40expectError(ignoreAllSubprocess.stdio[3].destroy());3940const ignoreAllResult = await ignoreAllSubprocess;41expectType<undefined>(ignoreAllResult.stdout);42expectType<undefined>(ignoreAllResult.stdio[1]);
30 unmodified lines
73expectType<null>(ignoreStdoutSubprocess.stdio[1]);74expectType<Readable>(ignoreStdoutSubprocess.stderr);75expectType<Readable>(ignoreStdoutSubprocess.stdio[2]);76expectType<Readable>(ignoreStdoutSubprocess.all);79expectError(ignoreStdoutSubprocess.stdio[3].destroy());7778const ignoreStdoutResult = await ignoreStdoutSubprocess;79expectType<undefined>(ignoreStdoutResult.stdout);80expectType<string>(ignoreStdoutResult.stderr);
6 unmodified lines
87expectType<Readable>(ignoreStderrSubprocess.stdio[1]);88expectType<null>(ignoreStderrSubprocess.stderr);89expectType<null>(ignoreStderrSubprocess.stdio[2]);90expectType<Readable>(ignoreStderrSubprocess.all);94expectError(ignoreStderrSubprocess.stdio[3].destroy());9192const ignoreStderrResult = await ignoreStderrSubprocess;93expectType<string>(ignoreStderrResult.stdout);94expectType<undefined>(ignoreStderrResult.stderr);
55 unmodified lines
modified:test-d/return/no-buffer-main.test-d.ts-1 removed
13 unmodified lines
14expectType<Readable>(noBufferSubprocess.stdio[1]);15expectType<Readable>(noBufferSubprocess.stderr);16expectType<Readable>(noBufferSubprocess.stdio[2]);17expectType<Readable>(noBufferSubprocess.all);18expectError(noBufferSubprocess.stdio[3].destroy());1819const noBufferResult = await noBufferSubprocess;20expectType<undefined>(noBufferResult.stdout);21expectType<undefined>(noBufferResult.stdio[1]);
23 unmodified lines
modified:test-d/return/result-main.test-d.ts+2 added-2 removed
33 unmodified lines
34expectType<keyof SignalConstants | undefined>(unicornsResult.signal);35expectType<string | undefined>(unicornsResult.signalDescription);36expectType<string>(unicornsResult.cwd);37expectType<number>(unicornsResult.durationMs);38expectType<Result[]>(unicornsResult.pipedFrom);38expectType<Array<Result | ExecaError>>(unicornsResult.pipedFrom);3940const unicornsResultSync = execaSync('unicorns', {all: true});41expectAssignable<SyncResult>(unicornsResultSync);42expectType<string>(unicornsResultSync.command);
32 unmodified lines
75 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}8182const errorSync = new Error('.');83if (errorSync instanceof ExecaSyncError) {
21 unmodified lines
modified:test-d/return/result-stdio.test-d.ts+18 added
152 unmodified lines
153expectType<undefined>(undefinedFd3Result.stdio[3]);154155const undefinedArrayFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [undefined] as const]});156expectType<undefined>(undefinedArrayFd3Result.stdio[3]);157158const ipcResult = await execa('unicorns', {ipc: true});159expectType<[undefined, string, string, undefined]>(ipcResult.stdio);160161const ipcInputResult = await execa('unicorns', {ipcInput: ''});162expectType<[undefined, string, string, undefined]>(ipcInputResult.stdio);163164const gracefulCancelResult = await execa('unicorns', {cancelSignal: AbortSignal.abort(), gracefulCancel: true});165expectType<[undefined, string, string, undefined]>(gracefulCancelResult.stdio);166167const fd3IpcResult = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], ipc: true});168expectType<[undefined, string, string, string, undefined]>(fd3IpcResult.stdio);169170const noIpcResult = await execa('unicorns');171expectType<[undefined, string, string]>(noIpcResult.stdio);172173const noIpcResultSync = execaSync('unicorns');174expectType<[undefined, string, string]>(noIpcResultSync.stdio);
modified:test-d/subprocess/stdio.test-d.ts+28 added-3 removed
13 unmodified lines
14expectType<Readable>(bufferSubprocess.stdio[1]);15expectType<Readable>(bufferSubprocess.stderr);16expectType<Readable>(bufferSubprocess.stdio[2]);17expectType<Readable>(bufferSubprocess.all);18expectError(bufferSubprocess.stdio[3].destroy());18expectType<Writable>(bufferSubprocess.stdio[0]);1920const hexSubprocess = execa('unicorns', {encoding: 'hex', all: true});21expectType<Writable>(hexSubprocess.stdin);22expectType<Writable>(hexSubprocess.stdio[0]);
1 unmodified line
24expectType<Readable>(hexSubprocess.stdio[1]);25expectType<Readable>(hexSubprocess.stderr);26expectType<Readable>(hexSubprocess.stdio[2]);27expectType<Readable>(hexSubprocess.all);28expectError(hexSubprocess.stdio[3].destroy());28expectType<Writable>(hexSubprocess.stdio[0]);2930const multipleStdinSubprocess = execa('unicorns', {stdin: ['inherit', 'pipe']});31expectType<Writable>(multipleStdinSubprocess.stdin);32
4 unmodified lines
37expectType<Readable>(multipleStdoutSubprocess.stdio[1]);38expectType<Readable>(multipleStdoutSubprocess.stderr);39expectType<Readable>(multipleStdoutSubprocess.stdio[2]);40expectType<Readable>(multipleStdoutSubprocess.all);41expectError(multipleStdoutSubprocess.stdio[3].destroy());41expectType<Writable>(multipleStdoutSubprocess.stdio[0]);4243const inputPipeSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input: true}]});44expectType<Writable>(inputPipeSubprocess.stdio[3]);45
27 unmodified lines
7374const stderrInputPipeSubprocess = execa('unicorns', {stderr: {value: 'pipe', input: true}});75expectType<Readable>(stderrInputPipeSubprocess.stderr);76expectType<Readable>(stderrInputPipeSubprocess.stdio[2]);7778const noIpcSubprocess = execa('unicorns');79expectType<Writable>(noIpcSubprocess.stdio[0]);80expectType<Readable>(noIpcSubprocess.stdio[1]);81expectType<Readable>(noIpcSubprocess.stdio[2]);8283const ipcSubprocess = execa('unicorns', {ipc: true});84expectType<Writable>(ipcSubprocess.stdio[0]);85expectType<Readable>(ipcSubprocess.stdio[1]);86expectType<Readable>(ipcSubprocess.stdio[2]);87expectType<null>(ipcSubprocess.stdio[3]);8889const ipcInputSubprocess = execa('unicorns', {ipcInput: ''});90expectType<null>(ipcInputSubprocess.stdio[3]);9192const fd3IpcSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], ipc: true});93expectType<Readable>(fd3IpcSubprocess.stdio[3]);94expectType<null>(fd3IpcSubprocess.stdio[4]);9596const fd5IpcSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe'], ipc: true});97expectType<Readable>(fd5IpcSubprocess.stdio[5]);98expectType<null>(fd5IpcSubprocess.stdio[6]);99expectType<Readable | Writable | null>(fd5IpcSubprocess.stdio[7]);100101expectType<Readable | Writable | null>(noIpcSubprocess.stdio[3]);
modified:types/arguments/options.d.ts+3 added-3 removed
190 unmodified lines
191 Largest amount of data allowed on `stdout`, `stderr` and `stdio`.192193 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.194195 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.196197 When reached, `error.isMaxBuffer` becomes `true`.198199 @default 100_000_000
52 unmodified lines
252 */253 readonly reject?: boolean;254255 /**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).257258 On timeout, `error.timedOut` becomes `true`.259260 @default 0
40 unmodified lines
301 */302 readonly gracefulCancel?: Unless<IsSync, boolean>;303304 /**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.306307 When this happens, `error.isForcefullyTerminated` becomes `true`.308309 @default 5000
120 unmodified lines
modified:types/return/result-stdio.d.ts+14 added-10 removed
1import type {StdioOptionNormalizedArray} from '../stdio/array.js';2import type {CommonOptions} from '../arguments/options.js';2import type {HasIpc} from '../ipc.js';3import type {CommonOptions, Options, StricterOptions} from '../arguments/options.js';4import type {ResultStdioNotAll} from './result-stdout.js';56// `result.stdio`6export 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 output8export type ResultStdioArray<OptionsType extends CommonOptions> = MapResultStdio<StdioOptionNormalizedArray<OptionsType>, OptionsType>;910type 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];2223export {};
modified:types/return/result.d.ts+4 added-2 removed
1import type {SignalConstants} from 'node:os';2import type {Unless} from '../utils.js';3import type {CommonOptions, Options, SyncOptions} from '../arguments/options.js';4import type {ErrorProperties} from './final-error.js';4import type {ErrorProperties, ExecaError} from './final-error.js';5import type {ResultAll} from './result-all.js';6import type {ResultStdioArray} from './result-stdio.js';7import type {ResultStdioNotAll} from './result-stdout.js';8import type {ResultIpcOutput} from './result-ipc.js';
35 unmodified lines
44 The output of the subprocess on `stdin`, `stdout`, `stderr` and other file descriptors.4546 Items are `undefined` when their corresponding `stdio` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.4748 With the `ipc` option, the last item is the subprocess' IPC channel, which is always `undefined`.4950 Items are arrays when their corresponding `stdio` option is a transform in object mode.51 */52 stdio: ResultStdioArray<OptionsType>;53
8 unmodified lines
62 Results of the other subprocesses that were piped into this subprocess.6364 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>, []>;6768 /**69 The file and arguments that were run.70 */
135 unmodified lines
modified:types/subprocess/stdio.d.ts+11 added-7 removed
1import type {Readable, Writable} from 'node:stream';2import type {StdioOptionNormalizedArray} from '../stdio/array.js';3import type {HasIpc} from '../ipc.js';4import type {Options} from '../arguments/options.js';5import type {SubprocessStdioStream} from './stdout.js';67// `subprocess.stdio`8export type SubprocessStdioArray<OptionsType extends Options> = MapStdioStreams<StdioOptionNormalizedArray<OptionsType>, OptionsType>;98// 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.13type 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];2324export {};
modified:types/subprocess/subprocess.d.ts+5 added-3 removed
70 unmodified lines
7172 /**73 The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.7475 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>;7879 /**80 The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.8182 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>;8586 /**87 The subprocess `stdin`, `stdout`, `stderr` and other files descriptors as an array of streams.8889 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`.9091 With the `ipc` option, the last item is the subprocess' IPC channel, which is always `null`.92 */93 stdio: SubprocessStdioArray<OptionsType>;9495 /**
55 unmodified lines
modified:types/verbose.d.ts+2 added-2 removed
26 unmodified lines
27 - `'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;3435 /**
15 unmodified lines
51 */52 timestamp: Date;5354 /**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