Skip to content
Myr

api.md

This file

Path

docs/api.md

1,084 lines · 43.1 KiB · Markdown

Last changed by

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

History of this file

Take it

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1–17why, one step back
1<picture>
2 <source media="(prefers-color-scheme: dark)" srcset="../media/logo_dark.svg">3 <img alt="execa logo" src="../media/logo.svg" width="400">4</picture>5<br>67# 📔 API reference89This lists all available [methods](#methods) and their [options](#options). This also describes the properties of the [subprocess](#subprocess), [result](#result) and [error](#execaerror) they return.1011## Methods1213### execa(file, arguments?, options?)1415`file`: `string | URL`\16`arguments`: `string[]`\17`options`: [`Options`](#options)\

Rename some types (#1009)ehmickybefore adoption2ef9186

line 18why, one step back
18_Returns_: [`ResultPromise`](#return-value)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 19–28why, one step back
19
20Executes a command using `file ...arguments`.2122More info on the [syntax](execution.md#array-syntax) and [escaping](escaping.md#array-syntax).2324### execa\`command\`25### execa(options)\`command\`2627`command`: `string`\28`options`: [`Options`](#options)\

Rename some types (#1009)ehmickybefore adoption2ef9186

line 29why, one step back
29_Returns_: [`ResultPromise`](#return-value)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 30–46why, one step back
30
31Executes a command. `command` is a [template string](execution.md#template-string-syntax) that includes both the `file` and its `arguments`.3233More info on the [syntax](execution.md#template-string-syntax) and [escaping](escaping.md#template-string-syntax).3435### execa(options)3637`options`: [`Options`](#options)\38_Returns_: [`execa`](#execafile-arguments-options)3940Returns a new instance of Execa but with different default [`options`](#options). Consecutive calls are merged to previous ones.4142[More info.](execution.md#globalshared-options)4344### execaSync(file, arguments?, options?)45### execaSync\`command\`46

Rename some types (#1009)ehmickybefore adoption2ef9186

line 47why, one step back
47_Returns_: [`SyncResult`](#return-value)

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 48why, one step back
48

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 49–59why, one step back
49Same as [`execa()`](#execafile-arguments-options) but synchronous.
5051Returns or throws a subprocess [`result`](#result). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available.5253[More info.](execution.md#synchronous-execution)5455### $(file, arguments?, options?)5657`file`: `string | URL`\58`arguments`: `string[]`\59`options`: [`Options`](#options)\

Rename some types (#1009)ehmickybefore adoption2ef9186

line 60why, one step back
60_Returns_: [`ResultPromise`](#return-value)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 61–74why, one step back
61
62Same as [`execa()`](#execafile-arguments-options) but using [script-friendly default options](scripts.md#script-files).6364Just like `execa()`, this can use the [template string syntax](execution.md#template-string-syntax) or [bind options](execution.md#globalshared-options). It can also be [run synchronously](#execasyncfile-arguments-options) using `$.sync()` or `$.s()`.6566This is the preferred method when executing multiple commands in a script file.6768[More info.](scripts.md)6970### execaNode(scriptPath, arguments?, options?)7172`scriptPath`: `string | URL`\73`arguments`: `string[]`\74`options`: [`Options`](#options)\

Rename some types (#1009)ehmickybefore adoption2ef9186

line 75why, one step back
75_Returns_: [`ResultPromise`](#return-value)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 76–85why, one step back
76
77Same as [`execa()`](#execafile-arguments-options) but using the [`node: true`](#optionsnode) option.78Executes a Node.js file using `node scriptPath ...arguments`.7980Just like `execa()`, this can use the [template string syntax](execution.md#template-string-syntax) or [bind options](execution.md#globalshared-options).8182This is the preferred method when executing Node.js files.8384[More info.](node.md)85

Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3

line 86why, one step back
86### parseCommandString(command)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 87–88why, one step back
87
88`command`: `string`\

Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3

line 89why, one step back
89_Returns_: `string[]`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 90why, one step back
90

Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3

line 91why, one step back
91Split a `command` string into an array. For example, `'npm run build'` returns `['npm', 'run', 'build']` and `'argument otherArgument'` returns `['argument', 'otherArgument']`.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 92–94why, one step back
92
93[More info.](escaping.md#user-defined-input)94

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 95–125why, one step back
95### sendMessage(message)
9697`message`: [`Message`](ipc.md#message-type)\98_Returns_: `Promise<void>`99100Send a `message` to the parent process.101102This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.103104[More info.](ipc.md#exchanging-messages)105106### getOneMessage()107108_Returns_: [`Promise<Message>`](ipc.md#message-type)109110Receive a single `message` from the parent process.111112This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.113114[More info.](ipc.md#exchanging-messages)115116### getEachMessage()117118_Returns_: [`AsyncIterable<Message>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)119120Iterate over each `message` from the parent process.121122This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.123124[More info.](ipc.md#listening-to-messages)125

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 126why, one step back
126## Return value

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 127why, one step back
127

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

lines 128–129why, one step back
128_TypeScript:_ [`ResultPromise`](typescript.md)\
129_Type:_ `Promise<object> | Subprocess`

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 130why, one step back
130

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 131why, one step back
131The return value of all [asynchronous methods](#methods) is both:

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

lines 132–133why, one step back
132- the [subprocess](#subprocess).
133- a `Promise` either resolving with its successful [`result`](#result), or rejecting with its [`error`](#execaerror).

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 134–136why, one step back
134
135[More info.](execution.md#subprocess)136

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

lines 137–138why, one step back
137## Subprocess
138

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 139why, one step back
139_TypeScript:_ [`Subprocess`](typescript.md)

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

lines 140–142why, one step back
140
141[`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following methods and properties.142

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 143–185why, one step back
143### subprocess\[Symbol.asyncIterator\]()
144145_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)146147Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.148149[More info.](lines.md#progressive-splitting)150151### subprocess.iterable(readableOptions?)152153`readableOptions`: [`ReadableOptions`](#readableoptions)\154_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)155156Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.157158[More info.](lines.md#progressive-splitting)159160### subprocess.pipe(file, arguments?, options?)161162`file`: `string | URL`\163`arguments`: `string[]`\164`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\165_Returns_: [`Promise<Result>`](#result)166167[Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the subprocess' [`stdout`](#subprocessstdout) to a second Execa subprocess' [`stdin`](#subprocessstdin). This resolves with that second subprocess' [result](#result). If either subprocess is rejected, this is rejected with that subprocess' [error](#execaerror) instead.168169This follows the same syntax as [`execa(file, arguments?, options?)`](#execafile-arguments-options) except both [regular options](#options) and [pipe-specific options](#pipeoptions) can be specified.170171[More info.](pipe.md#array-syntax)172173### subprocess.pipe\`command\`174### subprocess.pipe(options)\`command\`175176`command`: `string`\177`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\178_Returns_: [`Promise<Result>`](#result)179180Like [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using a [`command` template string](scripts.md#piping-stdout-to-another-command) instead. This follows the same syntax as `execa` [template strings](execution.md#template-string-syntax).181182[More info.](pipe.md#template-string-syntax)183184### subprocess.pipe(secondSubprocess, pipeOptions?)185

Rename some types (#1009)ehmickybefore adoption2ef9186

line 186why, one step back
186`secondSubprocess`: [`ResultPromise`](#return-value)\

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 187–189why, one step back
187`pipeOptions`: [`PipeOptions`](#pipeoptions)\
188_Returns_: [`Promise<Result>`](#result)189

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 190why, one step back
190Like [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using the [return value](#return-value) of another [`execa()`](#execafile-arguments-options) call instead.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 191–195why, one step back
191
192[More info.](pipe.md#advanced-syntax)193194#### pipeOptions195

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 196why, one step back
196_Type:_ `object`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 197–199why, one step back
197
198#### pipeOptions.from199

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 200–201why, one step back
200_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\
201_Default:_ `"stdout"`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 202–210why, one step back
202
203Which stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.204205`"all"` pipes both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.206207[More info.](pipe.md#source-file-descriptor)208209#### pipeOptions.to210

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 211–212why, one step back
211_Type:_ `"stdin" | "fd3" | "fd4" | ...`\
212_Default:_ `"stdin"`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 213–219why, one step back
213
214Which [stream](#subprocessstdin) to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.215216[More info.](pipe.md#destination-file-descriptor)217218#### pipeOptions.unpipeSignal219

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 220why, one step back
220_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 221–232why, one step back
221
222Unpipe the subprocess when the signal aborts.223224[More info.](pipe.md#unpipe)225226### subprocess.kill(signal, error?)227### subprocess.kill(error?)228229`signal`: `string | number`\230`error`: `Error`\231_Returns_: `boolean`232

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 233why, one step back
233Sends a [signal](https://nodejs.org/api/os.html#signal-constants) to the subprocess. The default signal is the [`killSignal`](#optionskillsignal) option. `killSignal` defaults to `SIGTERM`, which [terminates](#erroristerminated) the subprocess.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 234–242why, one step back
234
235This returns `false` when the signal could not be sent, for example when the subprocess has already exited.236237When 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).238239[More info.](termination.md)240241### subprocess.pid242

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 243why, one step back
243_Type:_ `number | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 244–250why, one step back
244
245Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).246247This is `undefined` if the subprocess failed to spawn.248249[More info.](termination.md#inter-process-termination)250

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 251why, one step back
251### subprocess.sendMessage(message)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 252why, one step back
252

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 253–254why, one step back
253`message`: [`Message`](ipc.md#message-type)\
254_Returns_: `Promise<void>`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 255why, one step back
255

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 256why, one step back
256Send a `message` to the subprocess.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 257why, one step back
257

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 258why, one step back
258This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 259–261why, one step back
259
260[More info.](ipc.md#exchanging-messages)261

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 262why, one step back
262### subprocess.getOneMessage()

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 263why, one step back
263

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 264why, one step back
264_Returns_: [`Promise<Message>`](ipc.md#message-type)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 265why, one step back
265

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 266why, one step back
266Receive a single `message` from the subprocess.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 267why, one step back
267

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 268why, one step back
268This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 269–271why, one step back
269
270[More info.](ipc.md#exchanging-messages)271

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 272–281why, one step back
272### subprocess.getEachMessage()
273274_Returns_: [`AsyncIterable<Message>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)275276Iterate over each `message` from the subprocess.277278This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.279280[More info.](ipc.md#listening-to-messages)281

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 282–283why, one step back
282### subprocess.stdin
283

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 284why, one step back
284_Type:_ [`Writable | null`](https://nodejs.org/api/stream.html#class-streamwritable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 285–293why, one step back
285
286The subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.287288This is `null` if the [`stdin`](#optionsstdin) option is set to [`'inherit'`](input.md#terminal-input), [`'ignore'`](input.md#ignore-input), [`Readable`](streams.md#input) or [`integer`](input.md#terminal-input).289290[More info.](streams.md#manual-streaming)291292### subprocess.stdout293

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 294why, one step back
294_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 295–303why, one step back
295
296The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.297298This 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`.299300[More info.](streams.md#manual-streaming)301302### subprocess.stderr303

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 304why, one step back
304_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 305–313why, one step back
305
306The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.307308This 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`.309310[More info.](streams.md#manual-streaming)311312### subprocess.all313

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 314why, one step back
314_Type:_ [`Readable | undefined`](https://nodejs.org/api/stream.html#class-streamreadable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 315–325why, one step back
315
316Stream combining/interleaving [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).317318This requires the [`all`](#optionsall) option to be `true`.319320This is `undefined` if [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are 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`.321322More info on [interleaving](output.md#interleaved-output) and [streaming](streams.md#manual-streaming).323324### subprocess.stdio325

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 326why, one step back
326_Type:_ [`[Writable | null, Readable | null, Readable | null, ...Array<Writable | Readable | null>]`](https://nodejs.org/api/stream.html#class-streamreadable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 327–344why, one step back
327
328The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.329330Each 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`.331332[More info.](streams.md#manual-streaming)333334### subprocess.readable(readableOptions?)335336`readableOptions`: [`ReadableOptions`](#readableoptions)\337_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream338339Converts the subprocess to a readable stream.340341[More info.](streams.md#converting-a-subprocess-to-a-stream)342343#### readableOptions344

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 345why, one step back
345_Type:_ `object`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 346–348why, one step back
346
347#### readableOptions.from348

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 349–350why, one step back
349_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\
350_Default:_ `"stdout"`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 351–359why, one step back
351
352Which stream to read from the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.353354`"all"` reads both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.355356[More info.](streams.md#different-file-descriptor)357358#### readableOptions.binary359

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 360–361why, one step back
360_Type:_ `boolean`\
361_Default:_ `false` with [`subprocess.iterable()`](#subprocessiterablereadableoptions), `true` with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 362–372why, one step back
362
363If `false`, iterates over lines. Each line is a string.364365If `true`, iterates over arbitrary chunks of data. Each line is an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) (with [`subprocess.iterable()`](#subprocessiterablereadableoptions)) or a [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) (with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)).366367This is always `true` when the [`encoding`](#optionsencoding) option is binary.368369More info for [iterables](binary.md#iterable) and [streams](binary.md#streams).370371#### readableOptions.preserveNewlines372

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 373–374why, one step back
373_Type:_ `boolean`\
374_Default:_ `false` with [`subprocess.iterable()`](#subprocessiterablereadableoptions), `true` with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 375–390why, one step back
375
376If both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.377378[More info.](lines.md#iterable)379380### subprocess.writable(writableOptions?)381382`writableOptions`: [`WritableOptions`](#writableoptions)\383_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream384385Converts the subprocess to a writable stream.386387[More info.](streams.md#converting-a-subprocess-to-a-stream)388389#### writableOptions390

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 391why, one step back
391_Type:_ `object`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 392–394why, one step back
392
393#### writableOptions.to394

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 395–396why, one step back
395_Type:_ `"stdin" | "fd3" | "fd4" | ...`\
396_Default:_ `"stdin"`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 397–412why, one step back
397
398Which [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.399400[More info.](streams.md#different-file-descriptor)401402### subprocess.duplex(duplexOptions?)403404`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\405_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream406407Converts the subprocess to a duplex stream.408409[More info.](streams.md#converting-a-subprocess-to-a-stream)410411## Result412

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 413why, one step back
413_TypeScript:_ [`Result`](typescript.md) or [`SyncResult`](typescript.md\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 414why, one step back
414_Type:_ `object`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 415why, one step back
415

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 416why, one step back
416[Result](execution.md#result) of a subprocess successful execution.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 417–421why, one step back
417
418When the subprocess [fails](errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.419420### result.stdout421

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 422why, one step back
422_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 423–433why, one step back
423
424The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).425426This is `undefined` if the [`stdout`](#optionsstdout) option is set to only [`'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`.427428This is an array if the [`lines`](#optionslines) option is `true`, or if the `stdout` option is a [transform in object mode](transform.md#object-mode).429430[More info.](output.md#stdout-and-stderr)431432### result.stderr433

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 434why, one step back
434_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 435–445why, one step back
435
436The output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).437438This is `undefined` if the [`stderr`](#optionsstderr) option is set to only [`'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`.439440This is an array if the [`lines`](#optionslines) option is `true`, or if the `stderr` option is a [transform in object mode](transform.md#object-mode).441442[More info.](output.md#stdout-and-stderr)443444### result.all445

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 446why, one step back
446_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 447–459why, one step back
447
448The output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) interleaved.449450This requires the [`all`](#optionsall) option to be `true`.451452This is `undefined` if both [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to only [`'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`.453454This is an array if the [`lines`](#optionslines) option is `true`, or if either the `stdout` or `stderr` option is a [transform in object mode](transform.md#object-mode).455456[More info.](output.md#interleaved-output)457458### result.stdio459

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 460why, one step back
460_Type:_ `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 461–471why, one step back
461
462The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).463464Items 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`.465466Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).467468[More info.](output.md#additional-file-descriptors)469470### result.pipedFrom471

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 472why, one step back
472_Type:_ [`Array<Result | ExecaError>`](#result)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 473–481why, one step back
473
474[Results](#result) of the other subprocesses that were piped into this subprocess.475476This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.477478[More info.](pipe.md#result)479480### result.command481

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 482why, one step back
482_Type:_ `string`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 483–489why, one step back
483
484The file and [arguments](input.md#command-arguments) that were run.485486[More info.](debugging.md#command)487488### result.escapedCommand489

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 490why, one step back
490_Type:_ `string`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 491–497why, one step back
491
492Same as [`command`](#resultcommand) but escaped.493494[More info.](debugging.md#command)495496### result.cwd497

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 498why, one step back
498_Type:_ `string`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 499–505why, one step back
499
500The [current directory](#optionscwd) in which the command was run.501502[More info.](environment.md#current-directory)503504### result.durationMs505

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 506why, one step back
506_Type:_ `number`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 507–513why, one step back
507
508Duration of the subprocess, in milliseconds.509510[More info.](debugging.md#duration)511512### result.failed513

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 514why, one step back
514_Type:_ `boolean`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 515–517why, one step back
515
516Whether the subprocess failed to run.517

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 518–519why, one step back
518When this is `true`, the result is an [`ExecaError`](#execaerror) instance with additional error-related properties.
519

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 520–521why, one step back
520[More info.](errors.md#subprocess-failure)
521

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 522–523why, one step back
522## ExecaError
523## ExecaSyncError

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 524why, one step back
524

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 525why, one step back
525_Type:_ `Error`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 526–536why, one step back
526
527Result of a subprocess [failed execution](errors.md#subprocess-failure).528529This error is thrown as an exception. If the [`reject`](#optionsreject) option is false, it is returned instead.530531This has the same shape as [successful results](#result), with the following additional properties.532533[More info.](errors.md)534535### error.message536

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 537why, one step back
537_Type:_ `string`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 538–544why, one step back
538
539Error message when the subprocess [failed](errors.md#subprocess-failure) to run.540541[More info.](errors.md#error-message)542543### error.shortMessage544

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 545why, one step back
545_Type:_ `string`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 546–552why, one step back
546
547This is the same as [`error.message`](#errormessage) except it does not include the subprocess [output](output.md).548549[More info.](errors.md#error-message)550551### error.originalMessage552

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 553why, one step back
553_Type:_ `string | undefined`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 554–560why, one step back
554
555Original error message. This is the same as [`error.message`](#errormessage) excluding the subprocess [output](output.md) and some additional information added by Execa.556557[More info.](errors.md#error-message)558559### error.cause560

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 561why, one step back
561_Type:_ `unknown | undefined`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 562–570why, one step back
562
563Underlying error, if there is one. For example, this is set by [`subprocess.kill(error)`](#subprocesskillerror).564565This is usually an `Error` instance.566567[More info.](termination.md#error-message-and-stack-trace)568569### error.code570

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 571why, one step back
571_Type:_ `string | undefined`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 572–576why, one step back
572
573Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.574575### error.timedOut576

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 577why, one step back
577_Type:_ `boolean`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 578–582why, one step back
578
579Whether the subprocess timed out due to the [`timeout`](#optionstimeout) option.580581[More info.](termination.md#timeout)582

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 583why, one step back
583### error.isCanceled

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 584why, one step back
584

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 585why, one step back
585_Type:_ `boolean`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 586–590why, one step back
586
587Whether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.588589[More info.](termination.md#canceling)590

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 591why, one step back
591### error.isMaxBuffer

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 592why, one step back
592

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 593why, one step back
593_Type:_ `boolean`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 594–598why, one step back
594
595Whether the subprocess failed because its output was larger than the [`maxBuffer`](#optionsmaxbuffer) option.596597[More info.](output.md#big-output)598

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 599why, one step back
599### error.isTerminated

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 600why, one step back
600

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 601why, one step back
601_Type:_ `boolean`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 602–608why, one step back
602
603Whether the subprocess was terminated by a [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) sent by either:604- The current process.605- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).606607[More info.](termination.md#signal-name-and-description)608

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 609why, one step back
609### error.exitCode

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 610why, one step back
610

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 611why, one step back
611_Type:_ `number | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 612–614why, one step back
612
613The numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.614

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 615why, one step back
615This is `undefined` when the subprocess could not be spawned or was terminated by a [signal](#errorsignal).

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 616–618why, one step back
616
617[More info.](errors.md#exit-code)618

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 619why, one step back
619### error.signal

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 620why, one step back
620

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 621why, one step back
621_Type:_ `string | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 622–630why, one step back
622
623The name of the [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) that terminated the subprocess, sent by either:624- The current process.625- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).626627If a signal terminated the subprocess, this property is defined and included in the [error message](#errormessage). Otherwise it is `undefined`.628629[More info.](termination.md#signal-name-and-description)630

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 631why, one step back
631### error.signalDescription

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 632why, one step back
632

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 633why, one step back
633_Type:_ `string | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 634–642why, one step back
634
635A human-friendly description of the [signal](termination.md#signal-termination) that was used to terminate the subprocess.636637If a signal terminated the subprocess, this property is defined and included in the error message. Otherwise it is `undefined`. It is also `undefined` when the signal is very uncommon which should seldomly happen.638639[More info.](termination.md#signal-name-and-description)640641## Options642

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 643why, one step back
643_TypeScript:_ [`Options`](typescript.md) or [`SyncOptions`](typescript.md\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 644why, one step back
644_Type:_ `object`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 645–651why, one step back
645
646This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).647648The following options [can specify different values](output.md#stdoutstderr-specific-options) for [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr): [`verbose`](#optionsverbose), [`lines`](#optionslines), [`stripFinalNewline`](#optionsstripfinalnewline), [`buffer`](#optionsbuffer), [`maxBuffer`](#optionsmaxbuffer).649650### options.preferLocal651

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 652–653why, one step back
652_Type:_ `boolean`\
653_Default:_ `true` with [`$`](#file-arguments-options), `false` otherwise

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 654–660why, one step back
654
655Prefer locally installed binaries when looking for a binary to execute.656657[More info.](environment.md#local-binaries)658659### options.localDir660

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 661–662why, one step back
661_Type:_ `string | URL`\
662_Default:_ [`cwd`](#optionscwd) option

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 663–669why, one step back
663
664Preferred path to find locally installed binaries, when using the [`preferLocal`](#optionspreferlocal) option.665666[More info.](environment.md#local-binaries)667668### options.node669

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 670–671why, one step back
670_Type:_ `boolean`\
671_Default:_ `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwise

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 672–674why, one step back
672
673If `true`, runs with Node.js. The first argument must be a Node.js file.674

Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5

lines 675–676why, one step back
675The subprocess inherits the current Node.js [CLI flags](https://nodejs.org/api/cli.html#options) and version. This can be overridden using the [`nodeOptions`](#optionsnodeoptions) and [`nodePath`](#optionsnodepath) options.
676

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 677–680why, one step back
677[More info.](node.md)
678679### options.nodeOptions680

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 681why, one step back
681_Type:_ `string[]`\

Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5

line 682why, one step back
682_Default:_ [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI flags)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 683–691why, one step back
683
684List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#optionsnodepath).685686Requires the [`node`](#optionsnode) option to be `true`.687688[More info.](node.md#nodejs-cli-flags)689690### options.nodePath691

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 692–693why, one step back
692_Type:_ `string | URL`\
693_Default:_ [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 694–702why, one step back
694
695Path to the Node.js executable.696697Requires the [`node`](#optionsnode) option to be `true`.698699[More info.](node.md#nodejs-version)700701### options.shell702

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 703–704why, one step back
703_Type:_ `boolean | string | URL`\
704_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 705–715why, one step back
705
706If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).707708Uses [`/bin/sh`](https://en.wikipedia.org/wiki/Unix_shell) on UNIX and [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.709710We [recommend against](shell.md#avoiding-shells) using this option.711712[More info.](shell.md)713714### options.cwd715

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 716–717why, one step back
716_Type:_ `string | URL`\
717_Default:_ `process.cwd()`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 718–726why, one step back
718
719Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.720721This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.722723[More info.](environment.md#current-directory)724725### options.env726

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 727–728why, one step back
727_Type:_ `object`\
728_Default:_ [`process.env`](https://nodejs.org/api/process.html#processenv)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 729–737why, one step back
729
730[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).731732Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).733734[More info.](input.md#environment-variables)735736### options.extendEnv737

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 738–739why, one step back
738_Type:_ `boolean`\
739_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 740–747why, one step back
740
741If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).742If `false`, only the `env` option is used, not `process.env`.743744[More info.](input.md#environment-variables)745746### options.input747

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 748why, one step back
748_Type:_ `string | Uint8Array | stream.Readable`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 749–757why, one step back
749
750Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).751752See also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options.753754[More info.](input.md#string-input)755756### options.inputFile757

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 758why, one step back
758_Type:_ `string | URL`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 759–767why, one step back
759
760Use a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).761762See also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options.763764[More info.](input.md#file-input)765766### options.stdin767

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 768why, one step back
768_TypeScript:_ [`StdinOption`](typescript.md) or [`StdinSyncOption`](typescript.md)\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 769–770why, one step back
769_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)\
770_Default:_ `'inherit'` with [`$`](#file-arguments-options), `'pipe'` otherwise

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 771–779why, one step back
771
772How to setup the subprocess' [standard input](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be [`'pipe'`](streams.md#manual-streaming), [`'overlapped'`](windows.md#asynchronous-io), [`'ignore`](input.md#ignore-input), [`'inherit'`](input.md#terminal-input), a [file descriptor integer](input.md#terminal-input), a [Node.js `Readable` stream](streams.md#input), a web [`ReadableStream`](streams.md#web-streams), a [`{ file: 'path' }` object](input.md#file-input), a [file URL](input.md#file-input), an [`Iterable`](streams.md#iterables-as-input) (including an [array of strings](input.md#string-input)), an [`AsyncIterable`](streams.md#iterables-as-input), an [`Uint8Array`](binary.md#binary-input), a [generator function](transform.md), a [`Duplex`](transform.md#duplextransform-streams) or a web [`TransformStream`](transform.md#duplextransform-streams).773774This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.775776More info on [available values](input.md), [streaming](streams.md) and [transforms](transform.md).777778### options.stdout779

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 780why, one step back
780_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 781–782why, one step back
781_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)\
782_Default:_ `pipe`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 783–791why, one step back
783
784How to setup the subprocess' [standard output](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be [`'pipe'`](output.md#stdout-and-stderr), [`'overlapped'`](windows.md#asynchronous-io), [`'ignore`](output.md#ignore-output), [`'inherit'`](output.md#terminal-output), a [file descriptor integer](output.md#terminal-output), a [Node.js `Writable` stream](streams.md#output), a web [`WritableStream`](streams.md#web-streams), a [`{ file: 'path' }` object](output.md#file-output), a [file URL](output.md#file-output), a [generator function](transform.md), a [`Duplex`](transform.md#duplextransform-streams) or a web [`TransformStream`](transform.md#duplextransform-streams).785786This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.787788More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).789790### options.stderr791

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 792why, one step back
792_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 793–794why, one step back
793_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)\
794_Default:_ `pipe`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 795–803why, one step back
795
796How to setup the subprocess' [standard error](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be [`'pipe'`](output.md#stdout-and-stderr), [`'overlapped'`](windows.md#asynchronous-io), [`'ignore`](output.md#ignore-output), [`'inherit'`](output.md#terminal-output), a [file descriptor integer](output.md#terminal-output), a [Node.js `Writable` stream](streams.md#output), a web [`WritableStream`](streams.md#web-streams), a [`{ file: 'path' }` object](output.md#file-output), a [file URL](output.md#file-output), a [generator function](transform.md), a [`Duplex`](transform.md#duplextransform-streams) or a web [`TransformStream`](transform.md#duplextransform-streams).797798This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.799800More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).801802### options.stdio803

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 804why, one step back
804_TypeScript:_ [`Options['stdio']`](typescript.md) or [`SyncOptions['stdio']`](typescript.md)\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 805–806why, one step back
805_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)\
806_Default:_ `pipe`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 807–817why, one step back
807
808Like the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options but for all [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) at once. For example, `{stdio: ['ignore', 'pipe', 'pipe']}` is the same as `{stdin: 'ignore', stdout: 'pipe', stderr: 'pipe'}`.809810A single string can be used [as a shortcut](output.md#shortcut).811812The array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr).813814More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).815816### options.all817

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 818–819why, one step back
818_Type:_ `boolean`\
819_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 820–826why, one step back
820
821Add a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.822823[More info.](output.md#interleaved-output)824825### options.encoding826

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 827–828why, one step back
827_Type:_ `'utf8' | 'utf16le' | 'buffer' | 'hex' | 'base64' | 'base64url' | 'latin1' | 'ascii'`\
828_Default:_ `'utf8'`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 829–841why, one step back
829
830If the subprocess outputs text, specifies its character encoding, either [`'utf8'`](https://en.wikipedia.org/wiki/UTF-8) or [`'utf16le'`](https://en.wikipedia.org/wiki/UTF-16).831832If it outputs binary data instead, this should be either:833- `'buffer'`: returns the binary output as an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).834- [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64), [`'base64url'`](https://en.wikipedia.org/wiki/Base64#URL_applications), [`'latin1'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings) or [`'ascii'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings): encodes the binary output as a string.835836The output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).837838[More info.](binary.md)839840### options.lines841

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 842–843why, one step back
842_Type:_ `boolean`\
843_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 844–854why, one step back
844
845Set [`result.stdout`](#resultstdout), [`result.stderr`](#resultstdout), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) as arrays of strings, splitting the subprocess' output into lines.846847This cannot be used if the [`encoding`](#optionsencoding) option is [binary](binary.md#binary-output).848849By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).850851[More info.](lines.md#simple-splitting)852853### options.stripFinalNewline854

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 855–856why, one step back
855_Type:_ `boolean`\
856_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 857–867why, one step back
857
858Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.859860If the [`lines`](#optionslines) option is true, this applies to each output line instead.861862By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).863864[More info.](lines.md#newlines)865866### options.maxBuffer867

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 868–869why, one step back
868_Type:_ `number`\
869_Default:_ `100_000_000`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 870–878why, one step back
870
871Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).872873By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).874875[More info.](output.md#big-output)876877### options.buffer878

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 879–880why, one step back
879_Type:_ `boolean`\
880_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 881–889why, one step back
881
882When `buffer` is `false`, the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties are not set.883884By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).885886[More info.](output.md#low-memory)887888### options.ipc889

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 890–891why, one step back
890_Type:_ `boolean`\
891_Default:_ `true` if the [`node`](#optionsnode) option is enabled, `false` otherwise

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 892why, one step back
892

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 893why, one step back
893Enables exchanging messages with the subprocess using [`subprocess.sendMessage(message)`](#subprocesssendmessagemessage), [`subprocess.getOneMessage()`](#subprocessgetonemessage) and [`subprocess.getEachMessage()`](#subprocessgeteachmessage).

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 894–898why, one step back
894
895[More info.](ipc.md)896897### options.serialization898

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 899–900why, one step back
899_Type:_ `'json' | 'advanced'`\
900_Default:_ `'advanced'`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 901–907why, one step back
901
902Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.903904[More info.](ipc.md#message-type)905906### options.verbose907

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 908–909why, one step back
908_Type:_ `'none' | 'short' | 'full'`\
909_Default:_ `'none'`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 910–920why, one step back
910
911If `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.912913If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.914915By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).916917[More info.](debugging.md#verbose-mode)918919### options.reject920

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 921–922why, one step back
921_Type:_ `boolean`\
922_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 923why, one step back
923

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 924why, one step back
924Setting this to `false` resolves the [result's promise](#return-value) with the [error](#execaerror) instead of rejecting it.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 925–929why, one step back
925
926[More info.](errors.md#preventing-exceptions)927928### options.timeout929

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 930–931why, one step back
930_Type:_ `number`\
931_Default:_ `0`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 932–934why, one step back
932
933If `timeout` is greater than `0`, the subprocess will be [terminated](#optionskillsignal) if it runs for longer than that amount of milliseconds.934

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 935why, one step back
935On timeout, [`result.timedOut`](#errortimedout) becomes `true`.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 936–940why, one step back
936
937[More info.](termination.md#timeout)938939### options.cancelSignal940

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 941why, one step back
941_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 942–944why, one step back
942
943You can abort the subprocess using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).944

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 945why, one step back
945When `AbortController.abort()` is called, [`result.isCanceled`](#erroriscanceled) becomes `true`.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 946–950why, one step back
946
947[More info.](termination.md#canceling)948949### options.forceKillAfterDelay950

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 951–952why, one step back
951_Type:_ `number | false`\
952_Default:_ `5000`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 953–959why, one step back
953
954If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).955956[More info.](termination.md#forceful-termination)957958### options.killSignal959

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 960–961why, one step back
960_Type:_ `string | number`\
961_Default:_ `'SIGTERM'`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 962–970why, one step back
962
963Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.964965This can be either a name (like [`'SIGTERM'`](termination.md#sigterm)) or a number (like `9`).966967[More info.](termination.md#default-signal)968969### options.detached970

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 971–972why, one step back
971_Type:_ `boolean`\
972_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 973–979why, one step back
973
974Run the subprocess independently from the current process.975976[More info.](environment.md#background-subprocess)977978### options.cleanup979

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 980–981why, one step back
980_Type:_ `boolean`\
981_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 982–988why, one step back
982
983Kill the subprocess when the current process exits.984985[More info.](termination.md#current-process-exit)986987### options.uid988

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 989–990why, one step back
989_Type:_ `number`\
990_Default:_ current user identifier

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 991–997why, one step back
991
992Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.993994[More info.](windows.md#uid-and-gid)995996### options.gid997

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 998–999why, one step back
998_Type:_ `number`\
999_Default:_ current group identifier

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1000–1006why, one step back
1000
1001Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.10021003[More info.](windows.md#uid-and-gid)10041005### options.argv01006

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 1007–1008why, one step back
1007_Type:_ `string`\
1008_Default:_ file being executed

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1009–1013why, one step back
1009
1010Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.10111012### options.windowsHide1013

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 1014–1015why, one step back
1014_Type:_ `boolean`\
1015_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1016–1022why, one step back
1016
1017On Windows, do not create a new console window.10181019[More info.](windows.md#console-window)10201021### options.windowsVerbatimArguments1022

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 1023–1024why, one step back
1023_Type:_ `boolean`\
1024_Default:_ `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwise

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1025–1039why, one step back
1025
1026If `false`, escapes the command arguments on Windows.10271028[More info.](windows.md#cmdexe-escaping)10291030## Transform options10311032A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.10331034A transform is either a [generator function](#transformoptionstransform) or a plain object with the following members.10351036[More info.](transform.md)10371038### transformOptions.transform1039

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 1040why, one step back
1040_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1041–1047why, one step back
1041
1042Map or [filter](transform.md#filtering) the [input](input.md) or [output](output.md) of the subprocess.10431044More info [here](transform.md#summary) and [there](transform.md#sharing-state).10451046### transformOptions.final1047

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 1048why, one step back
1048_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1049–1055why, one step back
1049
1050Create additional lines after the last one.10511052[More info.](transform.md#finalizing)10531054### transformOptions.binary1055

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 1056–1057why, one step back
1056_Type:_ `boolean`\
1057_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1058–1064why, one step back
1058
1059If `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.10601061[More info.](binary.md#transforms)10621063### transformOptions.preserveNewlines1064

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 1065–1066why, one step back
1065_Type:_ `boolean`\
1066_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1067–1073why, one step back
1067
1068If `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produces a single line.10691070[More info.](lines.md#transforms)10711072### transformOptions.objectMode1073

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 1074–1075why, one step back
1074_Type:_ `boolean`\
1075_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1076–1084why, one step back
1076
1077If `true`, allow [`transformOptions.transform`](#transformoptionstransform) and [`transformOptions.final`](#transformoptionsfinal) to return any type, not just `string` or `Uint8Array`.10781079[More info.](transform.md#object-mode)10801081<hr>10821083[**Previous**: 🔍 Differences with Bash and zx](bash.md)\1084[**Top**: Table of contents](../readme.md#documentation)