Skip to content
Myr

api.md

This file

Path

docs/api.md

1,202 lines · 47.1 KiB · Markdown

Last changed by

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

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 `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 95why, one step back
95### sendMessage(message, sendMessageOptions?)

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 96–97why, one step back
96
97`message`: [`Message`](ipc.md#message-type)\

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 98why, one step back
98`sendMessageOptions`: [`SendMessageOptions`](#sendmessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 99–106why, one step back
99_Returns_: `Promise<void>`
100101Send a `message` to the parent process.102103This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.104105[More info.](ipc.md#exchanging-messages)106

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

lines 107–119why, one step back
107#### sendMessageOptions
108109_Type_: `object`110111#### sendMessageOptions.strict112113_Type_: `boolean`\114_Default_: `false`115116Throw when the other process is not receiving or listening to messages.117118[More info.](ipc.md#ensure-messages-are-received)119

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

line 120why, one step back
120### getOneMessage(getOneMessageOptions?)

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 121why, one step back
121

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 122why, one step back
122`getOneMessageOptions`: [`GetOneMessageOptions`](#getonemessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 123–130why, one step back
123_Returns_: [`Promise<Message>`](ipc.md#message-type)
124125Receive a single `message` from the parent process.126127This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.128129[More info.](ipc.md#exchanging-messages)130

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

lines 131–142why, one step back
131#### getOneMessageOptions
132133_Type_: `object`134135#### getOneMessageOptions.filter136137_Type_: [`(Message) => boolean`](ipc.md#message-type)138139Ignore any `message` that returns `false`.140141[More info.](ipc.md#filter-messages)142

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

line 143why, one step back
143#### getOneMessageOptions.reference

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 144why, one step back
144

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

lines 145–154why, one step back
145_Type_: `boolean`\
146_Default_: `true`147148Keep the subprocess alive while `getOneMessage()` is waiting.149150[More info.](ipc.md#keeping-the-subprocess-alive)151152### getEachMessage(getEachMessageOptions?)153154`getEachMessageOptions`: [`GetEachMessageOptions`](#geteachmessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

lines 163–175why, one step back
163#### getEachMessageOptions
164165_Type_: `object`166167#### getEachMessageOptions.reference168169_Type_: `boolean`\170_Default_: `true`171172Keep the subprocess alive while `getEachMessage()` is waiting.173174[More info.](ipc.md#keeping-the-subprocess-alive)175

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 176–185why, one step back
176### getCancelSignal()
177178_Returns_: [`Promise<AbortSignal>`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)179180Retrieves the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) shared by the [`cancelSignal`](#optionscancelsignal) option.181182This can only be called inside a subprocess. This requires the [`gracefulCancel`](#optionsgracefulcancel) option to be `true`.183184[More info.](termination.md#graceful-termination)185

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

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

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

line 187why, one step back
187

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

line 190why, one step back
190

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

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

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

lines 192–193why, one step back
192- the [subprocess](#subprocess).
193- 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 194–196why, one step back
194
195[More info.](execution.md#subprocess)196

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

lines 197–198why, one step back
197## Subprocess
198

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

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

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

lines 203–245why, one step back
203### subprocess\[Symbol.asyncIterator\]()
204205_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)206207Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.208209[More info.](lines.md#progressive-splitting)210211### subprocess.iterable(readableOptions?)212213`readableOptions`: [`ReadableOptions`](#readableoptions)\214_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)215216Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.217218[More info.](lines.md#progressive-splitting)219220### subprocess.pipe(file, arguments?, options?)221222`file`: `string | URL`\223`arguments`: `string[]`\224`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\225_Returns_: [`Promise<Result>`](#result)226227[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.228229This 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.230231[More info.](pipe.md#array-syntax)232233### subprocess.pipe\`command\`234### subprocess.pipe(options)\`command\`235236`command`: `string`\237`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\238_Returns_: [`Promise<Result>`](#result)239240Like [`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).241242[More info.](pipe.md#template-string-syntax)243244### subprocess.pipe(secondSubprocess, pipeOptions?)245

Rename some types (#1009)ehmickybefore adoption2ef9186

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

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

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

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

line 250why, one step back
250Like [`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 251–255why, one step back
251
252[More info.](pipe.md#advanced-syntax)253254#### pipeOptions255

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

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

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

lines 257–259why, one step back
257
258#### pipeOptions.from259

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

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

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

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

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

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

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

lines 273–279why, one step back
273
274Which [stream](#subprocessstdin) to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.275276[More info.](pipe.md#destination-file-descriptor)277278#### pipeOptions.unpipeSignal279

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

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

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

lines 281–292why, one step back
281
282Unpipe the subprocess when the signal aborts.283284[More info.](pipe.md#unpipe)285286### subprocess.kill(signal, error?)287### subprocess.kill(error?)288289`signal`: `string | number`\290`error`: `Error`\291_Returns_: `boolean`292

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

line 293why, one step back
293Sends 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 294–302why, one step back
294
295This returns `false` when the signal could not be sent, for example when the subprocess has already exited.296297When 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).298299[More info.](termination.md)300301### subprocess.pid302

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

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

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

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

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

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

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

line 312why, one step back
312

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 313why, one step back
313`message`: [`Message`](ipc.md#message-type)\

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 314why, one step back
314`sendMessageOptions`: [`SendMessageOptions`](#sendmessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 315why, one step back
315_Returns_: `Promise<void>`

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

line 316why, one step back
316

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

line 318why, one step back
318

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 319why, one step back
319This 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 320–322why, one step back
320
321[More info.](ipc.md#exchanging-messages)322

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

line 323why, one step back
323### subprocess.getOneMessage(getOneMessageOptions?)

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

line 324why, one step back
324

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 325why, one step back
325`getOneMessageOptions`: [`GetOneMessageOptions`](#getonemessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

line 327why, one step back
327

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

line 329why, one step back
329

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 330why, one step back
330This 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 331–333why, one step back
331
332[More info.](ipc.md#exchanging-messages)333

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

line 334why, one step back
334### subprocess.getEachMessage(getEachMessageOptions?)

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 335why, one step back
335

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

line 336why, one step back
336`getEachMessageOptions`: [`GetEachMessageOptions`](#geteachmessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

lines 345–346why, one step back
345### subprocess.stdin
346

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

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

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

lines 348–356why, one step back
348
349The subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.350351This 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).352353[More info.](streams.md#manual-streaming)354355### subprocess.stdout356

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

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

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

lines 358–366why, one step back
358
359The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.360361This 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`.362363[More info.](streams.md#manual-streaming)364365### subprocess.stderr366

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

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

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

lines 368–376why, one step back
368
369The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.370371This 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`.372373[More info.](streams.md#manual-streaming)374375### subprocess.all376

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

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

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

lines 378–388why, one step back
378
379Stream combining/interleaving [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).380381This requires the [`all`](#optionsall) option to be `true`.382383This 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`.384385More info on [interleaving](output.md#interleaved-output) and [streaming](streams.md#manual-streaming).386387### subprocess.stdio388

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

line 389why, one step back
389_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 390–407why, one step back
390
391The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.392393Each 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`.394395[More info.](streams.md#manual-streaming)396397### subprocess.readable(readableOptions?)398399`readableOptions`: [`ReadableOptions`](#readableoptions)\400_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream401402Converts the subprocess to a readable stream.403404[More info.](streams.md#converting-a-subprocess-to-a-stream)405406#### readableOptions407

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

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

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

lines 409–411why, one step back
409
410#### readableOptions.from411

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

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

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

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

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

lines 423–424why, one step back
423_Type:_ `boolean`\
424_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 425–435why, one step back
425
426If `false`, iterates over lines. Each line is a string.427428If `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)).429430This is always `true` when the [`encoding`](#optionsencoding) option is binary.431432More info for [iterables](binary.md#iterable) and [streams](binary.md#streams).433434#### readableOptions.preserveNewlines435

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

lines 436–437why, one step back
436_Type:_ `boolean`\
437_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 438–453why, one step back
438
439If both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.440441[More info.](lines.md#iterable)442443### subprocess.writable(writableOptions?)444445`writableOptions`: [`WritableOptions`](#writableoptions)\446_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream447448Converts the subprocess to a writable stream.449450[More info.](streams.md#converting-a-subprocess-to-a-stream)451452#### writableOptions453

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

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

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

lines 455–457why, one step back
455
456#### writableOptions.to457

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

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

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

lines 460–475why, one step back
460
461Which [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.462463[More info.](streams.md#different-file-descriptor)464465### subprocess.duplex(duplexOptions?)466467`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\468_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream469470Converts the subprocess to a duplex stream.471472[More info.](streams.md#converting-a-subprocess-to-a-stream)473474## Result475

Improve documentation of signal handling (#1105)ehmickybefore adoption01a4b42

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

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

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

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

line 478why, one step back
478

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

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

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

lines 480–484why, one step back
480
481When the subprocess [fails](errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.482483### result.stdout484

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

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

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

lines 486–496why, one step back
486
487The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).488489This 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`.490491This 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).492493[More info.](output.md#stdout-and-stderr)494495### result.stderr496

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

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

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

lines 498–508why, one step back
498
499The output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).500501This 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`.502503This 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).504505[More info.](output.md#stdout-and-stderr)506507### result.all508

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

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

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

lines 510–522why, one step back
510
511The output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) interleaved.512513This requires the [`all`](#optionsall) option to be `true`.514515This 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`.516517This 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).518519[More info.](output.md#interleaved-output)520521### result.stdio522

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

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

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

lines 524–532why, one step back
524
525The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).526527Items 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`.528529Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).530531[More info.](output.md#additional-file-descriptors)532

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 533why, one step back
533### result.ipcOutput

Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de

line 534why, one step back
534

Fix type of `result.ipc` (#1071)ehmickybefore adoption69152ec

line 535why, one step back
535_Type_: [`Message[]`](ipc.md#message-type)

Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de

line 536why, one step back
536

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 537why, one step back
537All the messages [sent by the subprocess](#sendmessagemessage-sendmessageoptions) to the current process.

Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de

lines 538–542why, one step back
538
539This is empty unless the [`ipc`](#optionsipc) option is `true`. Also, this is empty if the [`buffer`](#optionsbuffer) option is `false`.540541[More info.](ipc.md#retrieve-all-messages)542

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

lines 543–544why, one step back
543### result.pipedFrom
544

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

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

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

lines 546–554why, one step back
546
547[Results](#result) of the other subprocesses that were piped into this subprocess.548549This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.550551[More info.](pipe.md#result)552553### result.command554

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

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

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

lines 556–562why, one step back
556
557The file and [arguments](input.md#command-arguments) that were run.558559[More info.](debugging.md#command)560561### result.escapedCommand562

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

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

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

lines 564–570why, one step back
564
565Same as [`command`](#resultcommand) but escaped.566567[More info.](debugging.md#command)568569### result.cwd570

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

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

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

lines 572–578why, one step back
572
573The [current directory](#optionscwd) in which the command was run.574575[More info.](environment.md#current-directory)576577### result.durationMs578

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

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

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

lines 580–586why, one step back
580
581Duration of the subprocess, in milliseconds.582583[More info.](debugging.md#duration)584585### result.failed586

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

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

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

lines 588–590why, one step back
588
589Whether the subprocess failed to run.590

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

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

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

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

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

lines 595–596why, one step back
595## ExecaError
596## ExecaSyncError

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

line 597why, one step back
597

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

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

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

lines 599–609why, one step back
599
600Result of a subprocess [failed execution](errors.md#subprocess-failure).601602This error is thrown as an exception. If the [`reject`](#optionsreject) option is false, it is returned instead.603604This has the same shape as [successful results](#result), with the following additional properties.605606[More info.](errors.md)607608### error.message609

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

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

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

lines 611–617why, one step back
611
612Error message when the subprocess [failed](errors.md#subprocess-failure) to run.613614[More info.](errors.md#error-message)615616### error.shortMessage617

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

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

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

lines 619–625why, one step back
619
620This is the same as [`error.message`](#errormessage) except it does not include the subprocess [output](output.md).621622[More info.](errors.md#error-message)623624### error.originalMessage625

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

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

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

lines 627–633why, one step back
627
628Original error message. This is the same as [`error.message`](#errormessage) excluding the subprocess [output](output.md) and some additional information added by Execa.629630[More info.](errors.md#error-message)631632### error.cause633

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

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

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

lines 635–643why, one step back
635
636Underlying error, if there is one. For example, this is set by [`subprocess.kill(error)`](#subprocesskillerror).637638This is usually an `Error` instance.639640[More info.](termination.md#error-message-and-stack-trace)641642### error.code643

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

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

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

lines 645–649why, one step back
645
646Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.647648### error.timedOut649

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

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

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

lines 651–655why, one step back
651
652Whether the subprocess timed out due to the [`timeout`](#optionstimeout) option.653654[More info.](termination.md#timeout)655

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

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

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

line 657why, one step back
657

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

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

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

lines 659–663why, one step back
659
660Whether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.661662[More info.](termination.md#canceling)663

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 664–671why, one step back
664### error.isGracefullyCanceled
665666_Type:_ `boolean`667668Whether the subprocess was canceled using both the [`cancelSignal`](#optionscancelsignal) and the [`gracefulCancel`](#optionsgracefulcancel) options.669670[More info.](termination.md#graceful-termination)671

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

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

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

line 673why, one step back
673

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

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

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

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

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

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

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

line 681why, one step back
681

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

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

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

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

Add `error.isForcefullyTerminated` (#1111)ehmickybefore adoptione69985d

lines 690–697why, one step back
690### error.isForcefullyTerminated
691692_Type:_ `boolean`693694Whether the subprocess was terminated by the [`SIGKILL`](termination.md#sigkill) signal sent by the [`forceKillAfterDelay`](#optionsforcekillafterdelay) option.695696[More info.](termination.md#forceful-termination)697

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

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

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

line 699why, one step back
699

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

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

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

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

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

line 704why, one step back
704This 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 705–707why, one step back
705
706[More info.](errors.md#exit-code)707

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

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

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

line 709why, one step back
709

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

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

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

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

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

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

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

line 721why, one step back
721

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

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

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

lines 723–731why, one step back
723
724A human-friendly description of the [signal](termination.md#signal-termination) that was used to terminate the subprocess.725726If 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.727728[More info.](termination.md#signal-name-and-description)729730## Options731

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

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

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

lines 734–740why, one step back
734
735This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).736737The 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).738739### options.preferLocal740

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

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

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

lines 743–749why, one step back
743
744Prefer locally installed binaries when looking for a binary to execute.745746[More info.](environment.md#local-binaries)747748### options.localDir749

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

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

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

lines 752–758why, one step back
752
753Preferred path to find locally installed binaries, when using the [`preferLocal`](#optionspreferlocal) option.754755[More info.](environment.md#local-binaries)756757### options.node758

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

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

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

lines 761–763why, one step back
761
762If `true`, runs with Node.js. The first argument must be a Node.js file.763

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

lines 764–765why, one step back
764The 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.
765

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

lines 766–769why, one step back
766[More info.](node.md)
767768### options.nodeOptions769

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

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

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

line 771why, one step back
771_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 772–780why, one step back
772
773List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#optionsnodepath).774775Requires the [`node`](#optionsnode) option to be `true`.776777[More info.](node.md#nodejs-cli-flags)778779### options.nodePath780

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

lines 781–782why, one step back
781_Type:_ `string | URL`\
782_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 783–791why, one step back
783
784Path to the Node.js executable.785786Requires the [`node`](#optionsnode) option to be `true`.787788[More info.](node.md#nodejs-version)789790### options.shell791

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

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

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

lines 794–804why, one step back
794
795If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).796797Uses [`/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.798799We [recommend against](shell.md#avoiding-shells) using this option.800801[More info.](shell.md)802803### options.cwd804

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

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

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

lines 807–815why, one step back
807
808Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.809810This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.811812[More info.](environment.md#current-directory)813814### options.env815

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

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

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

lines 818–826why, one step back
818
819[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).820821Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).822823[More info.](input.md#environment-variables)824825### options.extendEnv826

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

lines 827–828why, one step back
827_Type:_ `boolean`\
828_Default:_ `true`

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

lines 829–836why, one step back
829
830If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).831If `false`, only the `env` option is used, not `process.env`.832833[More info.](input.md#environment-variables)834835### options.input836

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

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

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

lines 838–846why, one step back
838
839Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).840841See also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options.842843[More info.](input.md#string-input)844845### options.inputFile846

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

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

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

lines 848–856why, one step back
848
849Use a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).850851See also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options.852853[More info.](input.md#file-input)854855### options.stdin856

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

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

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

lines 860–868why, one step back
860
861How 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).862863This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.864865More info on [available values](input.md), [streaming](streams.md) and [transforms](transform.md).866867### options.stdout868

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

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

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

lines 872–880why, one step back
872
873How 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).874875This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.876877More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).878879### options.stderr880

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

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

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

lines 884–892why, one step back
884
885How 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).886887This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.888889More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).890891### options.stdio892

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

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

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

lines 896–906why, one step back
896
897Like 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'}`.898899A single string can be used [as a shortcut](output.md#shortcut).900901The array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr).902903More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).904905### options.all906

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

lines 907–908why, one step back
907_Type:_ `boolean`\
908_Default:_ `false`

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

lines 909–915why, one step back
909
910Add a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.911912[More info.](output.md#interleaved-output)913914### options.encoding915

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

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

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

lines 918–930why, one step back
918
919If 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).920921If it outputs binary data instead, this should be either:922- `'buffer'`: returns the binary output as an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).923- [`'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.924925The output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).926927[More info.](binary.md)928929### options.lines930

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

lines 931–932why, one step back
931_Type:_ `boolean`\
932_Default:_ `false`

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

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

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

lines 944–945why, one step back
944_Type:_ `boolean`\
945_Default:_ `true`

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

lines 946–956why, one step back
946
947Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.948949If the [`lines`](#optionslines) option is true, this applies to each output line instead.950951By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).952953[More info.](lines.md#newlines)954955### options.maxBuffer956

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

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

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

lines 959–963why, one step back
959
960Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).961962By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).963

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 964–965why, one step back
964When reached, [`error.isMaxBuffer`](#errorismaxbuffer) becomes `true`.
965

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

lines 966–969why, one step back
966[More info.](output.md#big-output)
967968### options.buffer969

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

lines 970–971why, one step back
970_Type:_ `boolean`\
971_Default:_ `true`

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

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

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

line 981why, one step back
981_Type:_ `boolean`\

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

line 982why, one step back
982_Default:_ `true` if the [`node`](#optionsnode), [`ipcInput`](#optionsipcinput) or [`gracefulCancel`](#optionsgracefulcancel) option is set, `false` otherwise

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

line 983why, one step back
983

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

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

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

line 985why, one step back
985

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 986–987why, one step back
986The subprocess must be a Node.js file.
987

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

lines 988–991why, one step back
988[More info.](ipc.md)
989990### options.serialization991

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

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

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

lines 994–997why, one step back
994
995Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.996997[More info.](ipc.md#message-type)

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 998–1007why, one step back
998
999### options.ipcInput10001001_Type_: [`Message`](ipc.md#message-type)10021003Sends an IPC message when the subprocess starts.10041005The subprocess must be a [Node.js file](#optionsnode). The value's [type](ipc.md#message-type) depends on the [`serialization`](#optionsserialization) option.10061007More info [here](ipc.md#send-an-initial-message) and [there](input.md#any-input-type).

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

lines 1008–1010why, one step back
1008
1009### options.verbose1010

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

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

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

lines 1013–1015why, one step back
1013
1014If `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.1015

Log IPC messages with `verbose: 'full'` (#1063)ehmickybefore adoption839c2fe

line 1016why, one step back
1016If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), `stderr` and [IPC messages](ipc.md) are also printed.

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

lines 1017–1023why, one step back
1017
1018By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10191020[More info.](debugging.md#verbose-mode)10211022### options.reject1023

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

lines 1024–1025why, one step back
1024_Type:_ `boolean`\
1025_Default:_ `true`

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

line 1026why, one step back
1026

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

line 1027why, one step back
1027Setting 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 1028–1032why, one step back
1028
1029[More info.](errors.md#preventing-exceptions)10301031### options.timeout1032

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

lines 1033–1034why, one step back
1033_Type:_ `number`\
1034_Default:_ `0`

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

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

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

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

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

lines 1039–1043why, one step back
1039
1040[More info.](termination.md#timeout)10411042### options.cancelSignal1043

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

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

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

line 1045why, one step back
1045

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

line 1046why, one step back
1046When the `cancelSignal` is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), terminate the subprocess using a `SIGTERM` signal.

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

line 1047why, one step back
1047

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

line 1048why, one step back
1048When aborted, [`error.isCanceled`](#erroriscanceled) becomes `true`.

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

lines 1049–1050why, one step back
1049
1050[More info.](termination.md#canceling)

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 1051–1063why, one step back
1051
1052### options.gracefulCancel10531054_Type:_ `boolean`\1055_Default:_: `false`10561057When the [`cancelSignal`](#optionscancelsignal) option is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), do not send any [`SIGTERM`](termination.md#canceling). Instead, abort the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) returned by [`getCancelSignal()`](#getcancelsignal). The subprocess should use it to terminate gracefully.10581059The subprocess must be a [Node.js file](#optionsnode).10601061When aborted, [`error.isGracefullyCanceled`](#errorisgracefullycanceled) becomes `true`.10621063[More info.](termination.md#graceful-termination)

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

lines 1064–1066why, one step back
1064
1065### options.forceKillAfterDelay1066

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

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

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

lines 1069–1070why, one step back
1069
1070If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).

Add `error.isForcefullyTerminated` (#1111)ehmickybefore adoptione69985d

lines 1071–1072why, one step back
1071
1072When this happens, [`error.isForcefullyTerminated`](#errorisforcefullyterminated) becomes `true`.

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

lines 1073–1077why, one step back
1073
1074[More info.](termination.md#forceful-termination)10751076### options.killSignal1077

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

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

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

lines 1080–1088why, one step back
1080
1081Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.10821083This can be either a name (like [`'SIGTERM'`](termination.md#sigterm)) or a number (like `9`).10841085[More info.](termination.md#default-signal)10861087### options.detached1088

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

lines 1089–1090why, one step back
1089_Type:_ `boolean`\
1090_Default:_ `false`

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

lines 1091–1097why, one step back
1091
1092Run the subprocess independently from the current process.10931094[More info.](environment.md#background-subprocess)10951096### options.cleanup1097

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

lines 1098–1099why, one step back
1098_Type:_ `boolean`\
1099_Default:_ `true`

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

lines 1100–1106why, one step back
1100
1101Kill the subprocess when the current process exits.11021103[More info.](termination.md#current-process-exit)11041105### options.uid1106

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

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

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

lines 1109–1115why, one step back
1109
1110Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.11111112[More info.](windows.md#uid-and-gid)11131114### options.gid1115

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

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

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

lines 1118–1124why, one step back
1118
1119Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.11201121[More info.](windows.md#uid-and-gid)11221123### options.argv01124

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

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

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

lines 1127–1131why, one step back
1127
1128Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.11291130### options.windowsHide1131

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

lines 1132–1133why, one step back
1132_Type:_ `boolean`\
1133_Default:_ `true`

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

lines 1134–1140why, one step back
1134
1135On Windows, do not create a new console window.11361137[More info.](windows.md#console-window)11381139### options.windowsVerbatimArguments1140

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

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

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

lines 1143–1157why, one step back
1143
1144If `false`, escapes the command arguments on Windows.11451146[More info.](windows.md#cmdexe-escaping)11471148## Transform options11491150A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.11511152A transform is either a [generator function](#transformoptionstransform) or a plain object with the following members.11531154[More info.](transform.md)11551156### transformOptions.transform1157

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

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

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

lines 1159–1165why, one step back
1159
1160Map or [filter](transform.md#filtering) the [input](input.md) or [output](output.md) of the subprocess.11611162More info [here](transform.md#summary) and [there](transform.md#sharing-state).11631164### transformOptions.final1165

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

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

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

lines 1167–1173why, one step back
1167
1168Create additional lines after the last one.11691170[More info.](transform.md#finalizing)11711172### transformOptions.binary1173

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

lines 1174–1175why, one step back
1174_Type:_ `boolean`\
1175_Default:_ `false`

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

lines 1176–1182why, one step back
1176
1177If `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.11781179[More info.](binary.md#transforms)11801181### transformOptions.preserveNewlines1182

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

lines 1183–1184why, one step back
1183_Type:_ `boolean`\
1184_Default:_ `false`

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

lines 1185–1191why, one step back
1185
1186If `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produces a single line.11871188[More info.](lines.md#transforms)11891190### transformOptions.objectMode1191

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

lines 1192–1193why, one step back
1192_Type:_ `boolean`\
1193_Default:_ `false`

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

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