Skip to content
Myr

api.md

This file

Path

docs/api.md

1,369 lines · 55.0 KiB · Markdown

Last changed by

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

History of this file

Take it

The walk stopped after 200 commits: lines older than 42bea7f point at it.

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

lines 1–8why, 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 reference8

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 9why, one step back
9This lists all available [methods](#methods) and their [options](#options-1). This also describes the properties of the [subprocess](#subprocess), [result](#result) and [error](#execaerror) they return.

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

lines 10–16why, one step back
10
11## Methods1213### execa(file, arguments?, options?)1415`file`: `string | URL`\16`arguments`: `string[]`\

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 17why, one step back
17`options`: [`Options`](#options-1)\

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

lines 18–23why, one step back
18_Returns_: [`ResultPromise`](#return-value)
1920Executes a command using `file ...arguments`.2122More info on the [syntax](execution.md#array-syntax) and [escaping](escaping.md#array-syntax).23

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 24why, one step back
24### $(file, arguments?, options?)

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

line 25why, one step back
25

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 26–28why, one step back
26`file`: `string | URL`\
27`arguments`: `string[]`\28`options`: [`Options`](#options-1)\

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

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

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 31why, one step back
31Same as [`execa()`](#execafile-arguments-options) but using [script-friendly default options](scripts.md#script-files).

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

line 32why, one step back
32

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 33why, one step back
33This is the preferred method when executing multiple commands in a script file.

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

line 34why, one step back
34

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 35why, one step back
35[More info.](scripts.md)

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

line 36why, one step back
36

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 37why, one step back
37### execaNode(scriptPath, arguments?, options?)

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

line 38why, one step back
38

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 39–42why, one step back
39`scriptPath`: `string | URL`\
40`arguments`: `string[]`\41`options`: [`Options`](#options-1)\42_Returns_: [`ResultPromise`](#return-value)

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

line 43why, one step back
43

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 44–45why, one step back
44Same as [`execa()`](#execafile-arguments-options) but using the [`node: true`](#optionsnode) option.
45Executes a Node.js file using `node scriptPath ...arguments`.

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

line 46why, one step back
46

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 47–50why, one step back
47This is the preferred method when executing Node.js files.
4849[More info.](node.md)50

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

line 51why, one step back
51### execaSync(file, arguments?, options?)

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 52–53why, one step back
52### $.sync(file, arguments?, options?)
53### $.s(file, arguments?, options?)

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

line 54why, one step back
54

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 55–57why, one step back
55`file`: `string | URL`\
56`arguments`: `string[]`\57`options`: [`SyncOptions`](#options-1)\

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

lines 58–59why, one step back
58_Returns_: [`SyncResult`](#return-value)
59

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 60why, one step back
60Same as [`execa()`](#execafile-arguments-options) and [`$`](#file-arguments-options) but synchronous.

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

line 61why, one step back
61

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 62why, one step back
62Returns a subprocess [`result`](#result) or throws an [`error`](#execasyncerror). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available.

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

line 63why, one step back
63

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 64–65why, one step back
64Those methods are discouraged as they hold the CPU and lack multiple features.
65

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

lines 66–67why, one step back
66[More info.](execution.md#synchronous-execution)
67

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 68–73why, one step back
68### execa\`command\`
69### $\`command\`70### execaNode\`command\`71### execaSync\`command\`72### $.sync\`command\`73### $.s\`command\`

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

line 74why, one step back
74

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 75–76why, one step back
75`command`: `string`\
76_Returns_: [`ResultPromise`](#return-value), [`SyncResult`](#return-value)

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

line 77why, one step back
77

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 78why, one step back
78Same as [`execa()`](#execafile-arguments-options), [`$()`](#file-arguments-options), [`execaNode()`](#execanodescriptpath-arguments-options) and [`execaSync()`](#execasyncfile-arguments-options) but using a [template string](execution.md#template-string-syntax). `command` includes both the `file` and its `arguments`.

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

line 79why, one step back
79

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 80why, one step back
80More info on the [syntax](execution.md#template-string-syntax) and [escaping](escaping.md#template-string-syntax).

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

line 81why, one step back
81

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 82–87why, one step back
82### execa(options)\`command\`
83### $(options)\`command\`84### execaNode(options)\`command\`85### execaSync(options)\`command\`86### $.sync(options)\`command\`87### $.s(options)\`command\`

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

line 88why, one step back
88

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 89–91why, one step back
89`command`: `string`\
90`options`: [`Options`](#options-1), [`SyncOptions`](#options-1)\91_Returns_: [`ResultPromise`](#return-value), [`SyncResult`](#return-value)

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

line 92why, one step back
92

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 93why, one step back
93Same as [```execa`command` ```](#execacommand) but with [options](#options-1).

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

line 94why, one step back
94

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 95why, one step back
95[More info.](execution.md#template-string-syntax)

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

line 96why, one step back
96

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 97–102why, one step back
97### execa(options)
98### $(options)99### execaNode(options)100### execaSync(options)101### $.sync(options)102### $.s(options)

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

line 103why, one step back
103

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 104–105why, one step back
104`options`: [`Options`](#options-1), [`SyncOptions`](#options-1)\
105_Returns_: [`ExecaMethod`](#execafile-arguments-options), [`ExecaScriptMethod`](#file-arguments-options), [`ExecaNodeMethod`](#execanodescriptpath-arguments-options), [`ExecaSyncMethod`](#execasyncfile-arguments-options), [`ExecaScriptSyncMethod`](#syncfile-arguments-options)

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

line 106why, one step back
106

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 107why, one step back
107Returns a new instance of those methods but with different default [`options`](#options-1). Consecutive calls are merged to previous ones.

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

line 108why, one step back
108

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 109why, one step back
109[More info.](execution.md#globalshared-options)

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

line 110why, one step back
110

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

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

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

lines 112–113why, one step back
112
113`command`: `string`\

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

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

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

line 115why, one step back
115

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

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

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

lines 117–119why, one step back
117
118[More info.](escaping.md#user-defined-input)119

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

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

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

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

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

lines 132–144why, one step back
132#### sendMessageOptions
133134_Type_: `object`135136#### sendMessageOptions.strict137138_Type_: `boolean`\139_Default_: `false`140141Throw when the other process is not receiving or listening to messages.142143[More info.](ipc.md#ensure-messages-are-received)144

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

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

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 146why, one step back
146

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

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

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

lines 156–167why, one step back
156#### getOneMessageOptions
157158_Type_: `object`159160#### getOneMessageOptions.filter161162_Type_: [`(Message) => boolean`](ipc.md#message-type)163164Ignore any `message` that returns `false`.165166[More info.](ipc.md#filter-messages)167

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

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

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 169why, one step back
169

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

lines 170–179why, one step back
170_Type_: `boolean`\
171_Default_: `true`172173Keep the subprocess alive while `getOneMessage()` is waiting.174175[More info.](ipc.md#keeping-the-subprocess-alive)176177### getEachMessage(getEachMessageOptions?)178179`getEachMessageOptions`: [`GetEachMessageOptions`](#geteachmessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

lines 188–200why, one step back
188#### getEachMessageOptions
189190_Type_: `object`191192#### getEachMessageOptions.reference193194_Type_: `boolean`\195_Default_: `true`196197Keep the subprocess alive while `getEachMessage()` is waiting.198199[More info.](ipc.md#keeping-the-subprocess-alive)200

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

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

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

lines 211–212why, one step back
211## Return value
212

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 213why, one step back
213_TypeScript:_ [`ResultPromise`](typescript.md)\

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

line 214why, one step back
214_Type:_ `Subprocess`

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

lines 215–223why, one step back
215
216The return value of all [asynchronous methods](#methods) is both:217- the [subprocess](#subprocess).218- a `Promise` either resolving with its successful [`result`](#result), or rejecting with its [`error`](#execaerror).219220[More info.](execution.md#subprocess)221222## Subprocess223

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

line 225why, one step back
225

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

line 226why, one step back
226Promise with the following Execa-specific methods and properties.

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

line 227why, one step back
227

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

lines 228–229why, one step back
228The underlying Node.js [`ChildProcess`](https://nodejs.org/api/child_process.html#class-childprocess) instance is available as [`subprocess.nodeChildProcess`](#subprocessnodechildprocess). This is an escape hatch for Node.js-specific APIs that Execa does not document, such as `.on()`, `.send()`, `.disconnect()`, `.ref()` and `.unref()`.
229

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

lines 230–250why, one step back
230### subprocess\[Symbol.asyncIterator\]()
231232_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)233234Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.235236[More info.](lines.md#progressive-splitting)237238### subprocess.iterable(readableOptions?)239240`readableOptions`: [`ReadableOptions`](#readableoptions)\241_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)242243Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.244245[More info.](lines.md#progressive-splitting)246247### subprocess.pipe(file, arguments?, options?)248249`file`: `string | URL`\250`arguments`: `string[]`\

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 251why, one step back
251`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\

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

lines 252–255why, one step back
252_Returns_: [`Promise<Result>`](#result)
253254[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.255

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 256why, one step back
256This follows the same syntax as [`execa(file, arguments?, options?)`](#execafile-arguments-options) except both [regular options](#options-1) and [pipe-specific options](#pipeoptions) can be specified.

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

line 257why, one step back
257

Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c

lines 258–259why, one step back
258Like a subprocess, the return value can be [iterated](lines.md#progressive-splitting), [converted to a stream](streams.md#converting-a-subprocess-to-a-stream), or used for [IPC](ipc.md) with the destination subprocess.
259

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

lines 260–265why, one step back
260[More info.](pipe.md#array-syntax)
261262### subprocess.pipe\`command\`263### subprocess.pipe(options)\`command\`264265`command`: `string`\

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 266why, one step back
266`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\

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

lines 267–268why, one step back
267_Returns_: [`Promise<Result>`](#result)
268

Fix broken Markdown links (#1119)ehmickybefore adoption8572eb1

line 269why, one step back
269Like [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using a [`command` template string](execution.md#template-string-syntax) instead. This follows the same syntax as `execa` [template strings](execution.md#template-string-syntax).

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

lines 270–338why, one step back
270
271[More info.](pipe.md#template-string-syntax)272273### subprocess.pipe(secondSubprocess, pipeOptions?)274275`secondSubprocess`: [`ResultPromise`](#return-value)\276`pipeOptions`: [`PipeOptions`](#pipeoptions)\277_Returns_: [`Promise<Result>`](#result)278279Like [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using the [return value](#return-value) of another [`execa()`](#execafile-arguments-options) call instead.280281[More info.](pipe.md#advanced-syntax)282283#### pipeOptions284285_Type:_ `object`286287#### pipeOptions.from288289_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\290_Default:_ `"stdout"`291292Which stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.293294`"all"` pipes both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.295296[More info.](pipe.md#source-file-descriptor)297298#### pipeOptions.to299300_Type:_ `"stdin" | "fd3" | "fd4" | ...`\301_Default:_ `"stdin"`302303Which [stream](#subprocessstdin) to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.304305[More info.](pipe.md#destination-file-descriptor)306307#### pipeOptions.unpipeSignal308309_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)310311Unpipe the subprocess when the signal aborts.312313[More info.](pipe.md#unpipe)314315### subprocess.kill(signal, error?)316### subprocess.kill(error?)317318`signal`: `string | number`\319`error`: `Error`\320_Returns_: `boolean`321322Sends 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.323324This returns `false` when the signal could not be sent, for example when the subprocess has already exited.325326When 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).327328[More info.](termination.md)329330### subprocess.pid331332_Type:_ `number | undefined`333334Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).335336This is `undefined` if the subprocess failed to spawn.337338[More info.](termination.md#inter-process-termination)

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

lines 339–346why, one step back
339
340### subprocess.nodeChildProcess341342_Type:_ [`ChildProcess`](https://nodejs.org/api/child_process.html#class-childprocess)343344Underlying Node.js child process instance.345346This is intended as an escape hatch for Node.js-specific APIs that Execa does not document.

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

line 347why, one step back
347

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

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

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

line 349why, one step back
349

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

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

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

line 353why, one step back
353

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

line 355why, one step back
355

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

lines 357–359why, one step back
357
358[More info.](ipc.md#exchanging-messages)359

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

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

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

line 361why, one step back
361

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

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

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

line 364why, one step back
364

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

line 366why, one step back
366

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

lines 368–370why, one step back
368
369[More info.](ipc.md#exchanging-messages)370

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

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

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 372why, one step back
372

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

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

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

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

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

lines 382–397why, one step back
382### subprocess.stdin
383384_Type:_ [`Writable | null`](https://nodejs.org/api/stream.html#class-streamwritable)385386The subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.387388This 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).389390[More info.](streams.md#manual-streaming)391392### subprocess.stdout393394_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)395396The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.397

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

line 398why, one step back
398This is `null` if the [`stdout`](#optionsstdout) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output).

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

lines 399–407why, one step back
399
400[More info.](streams.md#manual-streaming)401402### subprocess.stderr403404_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)405406The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.407

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

line 408why, one step back
408This is `null` if the [`stderr`](#optionsstderr) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output).

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

lines 409–419why, one step back
409
410[More info.](streams.md#manual-streaming)411412### subprocess.all413414_Type:_ [`Readable | undefined`](https://nodejs.org/api/stream.html#class-streamreadable)415416Stream combining/interleaving [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).417418This requires the [`all`](#optionsall) option to be `true`.419

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

line 420why, one step back
420This is `undefined` if both [`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).

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

lines 421–429why, one step back
421
422More info on [interleaving](output.md#interleaved-output) and [streaming](streams.md#manual-streaming).423424### subprocess.stdio425426_Type:_ [`[Writable | null, Readable | null, Readable | null, ...Array<Writable | Readable | null>]`](https://nodejs.org/api/stream.html#class-streamreadable)427428The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.429

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

line 430why, one step back
430Each array item is `null` if the corresponding [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Stream`](streams.md#output) or [`integer`](output.md#terminal-output).

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

line 431why, one step back
431

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

lines 432–433why, one step back
432With the [`ipc`](#optionsipc) option, the last item is the subprocess' IPC channel, which is always `null`.
433

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

lines 434–512why, one step back
434[More info.](streams.md#manual-streaming)
435436### subprocess.readable(readableOptions?)437438`readableOptions`: [`ReadableOptions`](#readableoptions)\439_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream440441Converts the subprocess to a readable stream.442443[More info.](streams.md#converting-a-subprocess-to-a-stream)444445#### readableOptions446447_Type:_ `object`448449#### readableOptions.from450451_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\452_Default:_ `"stdout"`453454Which stream to read from the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.455456`"all"` reads both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.457458[More info.](streams.md#different-file-descriptor)459460#### readableOptions.binary461462_Type:_ `boolean`\463_Default:_ `false` with [`subprocess.iterable()`](#subprocessiterablereadableoptions), `true` with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)464465If `false`, iterates over lines. Each line is a string.466467If `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)).468469This is always `true` when the [`encoding`](#optionsencoding) option is binary.470471More info for [iterables](binary.md#iterable) and [streams](binary.md#streams).472473#### readableOptions.preserveNewlines474475_Type:_ `boolean`\476_Default:_ `false` with [`subprocess.iterable()`](#subprocessiterablereadableoptions), `true` with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)477478If both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.479480[More info.](lines.md#iterable)481482### subprocess.writable(writableOptions?)483484`writableOptions`: [`WritableOptions`](#writableoptions)\485_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream486487Converts the subprocess to a writable stream.488489[More info.](streams.md#converting-a-subprocess-to-a-stream)490491#### writableOptions492493_Type:_ `object`494495#### writableOptions.to496497_Type:_ `"stdin" | "fd3" | "fd4" | ...`\498_Default:_ `"stdin"`499500Which [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.501502[More info.](streams.md#different-file-descriptor)503504### subprocess.duplex(duplexOptions?)505506`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\507_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream508509Converts the subprocess to a duplex stream.510511[More info.](streams.md#converting-a-subprocess-to-a-stream)512

Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc

lines 513–539why, one step back
513### subprocess.readableStream(readableOptions?)
514515`readableOptions`: [`ReadableOptions`](#readableoptions)\516_Returns_: [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) web stream517518Converts the subprocess to a readable web stream.519520[More info.](streams.md#converting-a-subprocess-to-a-web-stream)521522### subprocess.writableStream(writableOptions?)523524`writableOptions`: [`WritableOptions`](#writableoptions)\525_Returns_: [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream) web stream526527Converts the subprocess to a writable web stream.528529[More info.](streams.md#converting-a-subprocess-to-a-web-stream)530531### subprocess.transformStream(duplexOptions?)532533`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\534_Returns_: [`{readable: ReadableStream, writable: WritableStream}`](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream)535536Converts the subprocess to a [`{readable, writable}`](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream) pair of web streams.537538[More info.](streams.md#converting-a-subprocess-to-a-web-stream)539

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

lines 540–541why, one step back
540## Result
541

Improve documentation of signal handling (#1105)ehmickybefore adoption01a4b42

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

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

lines 543–580why, one step back
543_Type:_ `object`
544545[Result](execution.md#result) of a subprocess successful execution.546547When the subprocess [fails](errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.548549### result.stdout550551_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`552553The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).554555This 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`.556557This 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).558559[More info.](output.md#stdout-and-stderr)560561### result.stderr562563_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`564565The output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).566567This 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`.568569This 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).570571[More info.](output.md#stdout-and-stderr)572573### result.all574575_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`576577The output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) interleaved.578579This requires the [`all`](#optionsall) option to be `true`.580

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

line 581why, one step back
581This 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` for both.

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

lines 582–594why, one step back
582
583This 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).584585[More info.](output.md#interleaved-output)586587### result.stdio588589_Type:_ `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`590591The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).592593Items are `undefined` when their corresponding [`stdio`](#optionsstdio) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.594

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

lines 595–596why, one step back
595With the [`ipc`](#optionsipc) option, the last item is the subprocess' IPC channel, which is always `undefined`.
596

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

lines 597–600why, one step back
597Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).
598599[More info.](output.md#additional-file-descriptors)600

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

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

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

line 602why, one step back
602

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

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

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

line 604why, one step back
604

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

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

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

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

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

lines 611–731why, one step back
611### result.pipedFrom
612613_Type:_ [`Array<Result | ExecaError>`](#result)614615[Results](#result) of the other subprocesses that were piped into this subprocess.616617This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.618619[More info.](pipe.md#result)620621### result.command622623_Type:_ `string`624625The file and [arguments](input.md#command-arguments) that were run.626627[More info.](debugging.md#command)628629### result.escapedCommand630631_Type:_ `string`632633Same as [`command`](#resultcommand) but escaped.634635[More info.](debugging.md#command)636637### result.cwd638639_Type:_ `string`640641The [current directory](#optionscwd) in which the command was run.642643[More info.](environment.md#current-directory)644645### result.durationMs646647_Type:_ `number`648649Duration of the subprocess, in milliseconds.650651[More info.](debugging.md#duration)652653### result.failed654655_Type:_ `boolean`656657Whether the subprocess failed to run.658659When this is `true`, the result is an [`ExecaError`](#execaerror) instance with additional error-related properties.660661[More info.](errors.md#subprocess-failure)662663## ExecaError664## ExecaSyncError665666_Type:_ `Error`667668Result of a subprocess [failed execution](errors.md#subprocess-failure).669670This error is thrown as an exception. If the [`reject`](#optionsreject) option is false, it is returned instead.671672This has the same shape as [successful results](#result), with the following additional properties.673674[More info.](errors.md)675676### error.message677678_Type:_ `string`679680Error message when the subprocess [failed](errors.md#subprocess-failure) to run.681682[More info.](errors.md#error-message)683684### error.shortMessage685686_Type:_ `string`687688This is the same as [`error.message`](#errormessage) except it does not include the subprocess [output](output.md).689690[More info.](errors.md#error-message)691692### error.originalMessage693694_Type:_ `string | undefined`695696Original error message. This is the same as [`error.message`](#errormessage) excluding the subprocess [output](output.md) and some additional information added by Execa.697698[More info.](errors.md#error-message)699700### error.cause701702_Type:_ `unknown | undefined`703704Underlying error, if there is one. For example, this is set by [`subprocess.kill(error)`](#subprocesskillerror).705706This is usually an `Error` instance.707708[More info.](termination.md#error-message-and-stack-trace)709710### error.code711712_Type:_ `string | undefined`713714Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.715716### error.timedOut717718_Type:_ `boolean`719720Whether the subprocess timed out due to the [`timeout`](#optionstimeout) option.721722[More info.](termination.md#timeout)723724### error.isCanceled725726_Type:_ `boolean`727728Whether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.729730[More info.](termination.md#canceling)731

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 732–739why, one step back
732### error.isGracefullyCanceled
733734_Type:_ `boolean`735736Whether the subprocess was canceled using both the [`cancelSignal`](#optionscancelsignal) and the [`gracefulCancel`](#optionsgracefulcancel) options.737738[More info.](termination.md#graceful-termination)739

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

lines 740–757why, one step back
740### error.isMaxBuffer
741742_Type:_ `boolean`743744Whether the subprocess failed because its output was larger than the [`maxBuffer`](#optionsmaxbuffer) option.745746[More info.](output.md#big-output)747748### error.isTerminated749750_Type:_ `boolean`751752Whether the subprocess was terminated by a [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) sent by either:753- The current process.754- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).755756[More info.](termination.md#signal-name-and-description)757

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

lines 758–765why, one step back
758### error.isForcefullyTerminated
759760_Type:_ `boolean`761762Whether the subprocess was terminated by the [`SIGKILL`](termination.md#sigkill) signal sent by the [`forceKillAfterDelay`](#optionsforcekillafterdelay) option.763764[More info.](termination.md#forceful-termination)765

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

lines 766–799why, one step back
766### error.exitCode
767768_Type:_ `number | undefined`769770The numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.771772This is `undefined` when the subprocess could not be spawned or was terminated by a [signal](#errorsignal).773774[More info.](errors.md#exit-code)775776### error.signal777778_Type:_ `string | undefined`779780The name of the [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) that terminated the subprocess, sent by either:781- The current process.782- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).783784If a signal terminated the subprocess, this property is defined and included in the [error message](#errormessage). Otherwise it is `undefined`.785786[More info.](termination.md#signal-name-and-description)787788### error.signalDescription789790_Type:_ `string | undefined`791792A human-friendly description of the [signal](termination.md#signal-termination) that was used to terminate the subprocess.793794If 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.795796[More info.](termination.md#signal-name-and-description)797798## Options799

Fix a typo (#1153)Reuben Thomasbefore adoption3fc8049

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

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

lines 801–831why, one step back
801_Type:_ `object`
802803This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).804805The 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).806807### options.preferLocal808809_Type:_ `boolean`\810_Default:_ `true` with [`$`](#file-arguments-options), `false` otherwise811812Prefer locally installed binaries when looking for a binary to execute.813814[More info.](environment.md#local-binaries)815816### options.localDir817818_Type:_ `string | URL`\819_Default:_ [`cwd`](#optionscwd) option820821Preferred path to find locally installed binaries, when using the [`preferLocal`](#optionspreferlocal) option.822823[More info.](environment.md#local-binaries)824825### options.node826827_Type:_ `boolean`\828_Default:_ `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwise829830If `true`, runs with Node.js. The first argument must be a Node.js file.831

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

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

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

lines 834–838why, one step back
834[More info.](node.md)
835836### options.nodeOptions837838_Type:_ `string[]`\

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

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

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

lines 840–884why, one step back
840
841List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#optionsnodepath).842843Requires the [`node`](#optionsnode) option to be `true`.844845[More info.](node.md#nodejs-cli-flags)846847### options.nodePath848849_Type:_ `string | URL`\850_Default:_ [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)851852Path to the Node.js executable.853854Requires the [`node`](#optionsnode) option to be `true`.855856[More info.](node.md#nodejs-version)857858### options.shell859860_Type:_ `boolean | string | URL`\861_Default:_ `false`862863If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).864865Uses [`/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.866867We [recommend against](shell.md#avoiding-shells) using this option.868869[More info.](shell.md)870871### options.cwd872873_Type:_ `string | URL`\874_Default:_ `process.cwd()`875876Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.877878This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.879880[More info.](environment.md#current-directory)881882### options.env883884_Type:_ `object`\

Fix `extendEnv: false` inheriting `process.env` when `env` is not setSindre Sorhusbefore adoption67acf60

line 885why, one step back
885_Default:_ `{}`

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

lines 886–898why, one step back
886
887[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).888889Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).890891[More info.](input.md#environment-variables)892893### options.extendEnv894895_Type:_ `boolean`\896_Default:_ `true`897898If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).

TweaksSindre Sorhusbefore adoption698a1b8

line 899why, one step back
899If `false`, only the `env` option is used, not `process.env`. However, when `env` has no `PATH`, the [`preferLocal`](#optionspreferlocal) and [`node`](#optionsnode) options still add their directories to `process.env.PATH`.

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

lines 900–924why, one step back
900
901[More info.](input.md#environment-variables)902903### options.input904905_Type:_ `string | Uint8Array | stream.Readable`906907Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).908909See also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options.910911[More info.](input.md#string-input)912913### options.inputFile914915_Type:_ `string | URL`916917Use a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).918919See also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options.920921[More info.](input.md#file-input)922923### options.stdin924

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

lines 926–936why, one step back
926_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)\
927_Default:_ `'inherit'` with [`$`](#file-arguments-options), `'pipe'` otherwise928929How 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).930931This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.932933More info on [available values](input.md), [streaming](streams.md) and [transforms](transform.md).934935### options.stdout936

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

lines 938–948why, one step back
938_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)\
939_Default:_ `pipe`940941How 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).942943This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.944945More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).946947### options.stderr948

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

lines 950–960why, one step back
950_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)\
951_Default:_ `pipe`952953How 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).954955This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.956957More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).958959### options.stdio960

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

Generalize `{value, input}` to any direction-ambiguous stdio value (#1249)Sindre Sorhusbefore adoption9fbf5ba

line 962why, one step back
962_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} | {value: 'pipe' | 'inherit' | number | URL | {file: string} | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}; input?: boolean}>` (or a tuple of those types)\

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

lines 963–968why, one step back
963_Default:_ `pipe`
964965Like 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'}`.966967A single string can be used [as a shortcut](output.md#shortcut).968

Generalize `{value, input}` to any direction-ambiguous stdio value (#1249)Sindre Sorhusbefore adoption9fbf5ba

line 969why, one step back
969The array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr). Some values have an ambiguous direction on an additional file descriptor (like `'pipe'`, `'inherit'`, a file or a transform), so they default to output. To use one for [input](input.md#additional-file-descriptors) instead, wrap it as `{value, input: true}`.

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

lines 970–990why, one step back
970
971More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).972973### options.all974975_Type:_ `boolean`\976_Default:_ `false`977978Add a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.979980[More info.](output.md#interleaved-output)981982### options.encoding983984_Type:_ `'utf8' | 'utf16le' | 'buffer' | 'hex' | 'base64' | 'base64url' | 'latin1' | 'ascii'`\985_Default:_ `'utf8'`986987If 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).988989If it outputs binary data instead, this should be either:990- `'buffer'`: returns the binary output as an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).

Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454

line 991why, one step back
991- [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64), [`'base64url'`](https://en.wikipedia.org/wiki/Base64#RFC_4648), [`'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.

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

lines 992–994why, one step back
992
993The output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).994

Fix the `encoding` option and line splitting in transformsSindre Sorhusbefore adoption6adb3c3

lines 995–996why, one step back
995String input passed with the [`input`](#optionsinput) or [`stdin`](#optionsstdin) option is always encoded with UTF-8, whatever this option is. With a text encoding, [`stdin` transforms](transform.md) also decode their input with UTF-8.
996

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

lines 997–1033why, one step back
997[More info.](binary.md)
998999### options.lines10001001_Type:_ `boolean`\1002_Default:_ `false`10031004Set [`result.stdout`](#resultstdout), [`result.stderr`](#resultstdout), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) as arrays of strings, splitting the subprocess' output into lines.10051006This cannot be used if the [`encoding`](#optionsencoding) option is [binary](binary.md#binary-output).10071008By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10091010[More info.](lines.md#simple-splitting)10111012### options.stripFinalNewline10131014_Type:_ `boolean`\1015_Default:_ `true`10161017Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.10181019If the [`lines`](#optionslines) option is true, this applies to each output line instead.10201021By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10221023[More info.](lines.md#newlines)10241025### options.maxBuffer10261027_Type:_ `number`\1028_Default:_ `100_000_000`10291030Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).10311032By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).1033

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

line 1034why, one step back
1034With [synchronous methods](execution.md#synchronous-execution), this cannot be enforced per file descriptor while the subprocess runs, since `spawnSync()` only accepts a single value, which limits the total output of all file descriptors. The `maxBuffer.stdout` value is used for it. The other file descriptors' own values are enforced from the output, once the subprocess ended, and cannot be higher than `maxBuffer.stdout`. Also, with synchronous methods, this is measured in bytes instead of [characters or lines](output.md#big-output), for the same reason.

Fix `maxBuffer` being ignored or wrongly appliedSindre Sorhusbefore adoption9547e51

line 1035why, one step back
1035

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

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

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

lines 1038–1053why, one step back
1038[More info.](output.md#big-output)
10391040### options.buffer10411042_Type:_ `boolean`\1043_Default:_ `true`10441045When `buffer` is `false`, the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties are not set.10461047By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10481049[More info.](output.md#low-memory)10501051### options.ipc10521053_Type:_ `boolean`\

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

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

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

line 1055why, one step back
1055

Fix broken Markdown links (#1119)ehmickybefore adoption8572eb1

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

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

line 1057why, one step back
1057

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

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

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

lines 1060–1069why, one step back
1060[More info.](ipc.md)
10611062### options.serialization10631064_Type:_ `'json' | 'advanced'`\1065_Default:_ `'advanced'`10661067Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.10681069[More info.](ipc.md#message-type)

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 1070–1079why, one step back
1070
1071### options.ipcInput10721073_Type_: [`Message`](ipc.md#message-type)10741075Sends an IPC message when the subprocess starts.10761077The subprocess must be a [Node.js file](#optionsnode). The value's [type](ipc.md#message-type) depends on the [`serialization`](#optionsserialization) option.10781079More info [here](ipc.md#send-an-initial-message) and [there](input.md#any-input-type).

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

lines 1080–1082why, one step back
1080
1081### options.verbose1082

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

line 1083why, one step back
1083_Type:_ `'none' | 'short' | 'full' | Function`\

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

lines 1084–1087why, one step back
1084_Default:_ `'none'`
10851086If `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.1087

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

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

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

line 1089why, one step back
1089

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 1090–1091why, one step back
1090A [function](#verbose-function) can be passed to customize logging. Please see [this page](debugging.md#custom-logging) for more information.
1091

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

lines 1092–1109why, one step back
1092By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).
10931094[More info.](debugging.md#verbose-mode)10951096### options.reject10971098_Type:_ `boolean`\1099_Default:_ `true`11001101Setting this to `false` resolves the [result's promise](#return-value) with the [error](#execaerror) instead of rejecting it.11021103[More info.](errors.md#preventing-exceptions)11041105### options.timeout11061107_Type:_ `number`\1108_Default:_ `0`1109

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

line 1110why, one step back
1110If `timeout` is greater than `0`, the subprocess will be [terminated](#optionskillsignal) if it runs for longer than that amount of milliseconds. It must be a non-negative integer, up to `2147483647` (about 24.8 days).

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

line 1111why, one step back
1111

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

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

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

lines 1113–1119why, one step back
1113
1114[More info.](termination.md#timeout)11151116### options.cancelSignal11171118_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)1119

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

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

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

line 1121why, one step back
1121

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

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

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

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

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 1125–1137why, one step back
1125
1126### options.gracefulCancel11271128_Type:_ `boolean`\1129_Default:_: `false`11301131When 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.11321133The subprocess must be a [Node.js file](#optionsnode).11341135When aborted, [`error.isGracefullyCanceled`](#errorisgracefullycanceled) becomes `true`.11361137[More info.](termination.md#graceful-termination)

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

lines 1138–1140why, one step back
1138
1139### options.forceKillAfterDelay1140

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

line 1141why, one step back
1141_Type:_ `number | boolean`\

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

lines 1142–1143why, one step back
1142_Default:_ `5000`
1143

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

line 1144why, one step back
1144If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL). The delay must be a non-negative integer, up to `2147483647` milliseconds (about 24.8 days). When `true`, the default `5000` is used. When `false`, the subprocess is not forcefully exited.

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

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

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

lines 1147–1178why, one step back
1147
1148[More info.](termination.md#forceful-termination)11491150### options.killSignal11511152_Type:_ `string | number`\1153_Default:_ `'SIGTERM'`11541155Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.11561157This can be either a name (like [`'SIGTERM'`](termination.md#sigterm)) or a number (like `9`).11581159[More info.](termination.md#default-signal)11601161### options.detached11621163_Type:_ `boolean`\1164_Default:_ `false`11651166Run the subprocess independently from the current process.11671168[More info.](environment.md#background-subprocess)11691170### options.cleanup11711172_Type:_ `boolean`\1173_Default:_ `true`11741175Kill the subprocess when the current process exits.11761177[More info.](termination.md#current-process-exit)1178

Add `killDescendants` option to also terminate descendant processes (#1256)Sindre Sorhusbefore adoption84fa0ec

lines 1179–1189why, one step back
1179### options.killDescendants
11801181_Type:_ `boolean`\1182_Default:_ `false`11831184When the subprocess is terminated by Execa, also terminate all of its descendant processes, instead of only the subprocess itself.11851186This is useful when the subprocess spawns its own processes, such as when using the [`shell`](#optionsshell) option.11871188On Unix, this spawns the subprocess in its own [process group](https://en.wikipedia.org/wiki/Process_group). On Windows, this uses [`taskkill`](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill).1189

TweaksSindre Sorhusbefore adoption698a1b8

line 1190why, one step back
1190This is best-effort: descendant processes that create their own process group or session are not terminated. Also, on Windows, descendants are not terminated once the subprocess exited, since its PID might then belong to an unrelated process.

Add `killDescendants` option to also terminate descendant processes (#1256)Sindre Sorhusbefore adoption84fa0ec

lines 1191–1193why, one step back
1191
1192[More info.](termination.md#killing-descendant-processes)1193

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

lines 1194–1234why, one step back
1194### options.uid
11951196_Type:_ `number`\1197_Default:_ current user identifier11981199Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.12001201[More info.](windows.md#uid-and-gid)12021203### options.gid12041205_Type:_ `number`\1206_Default:_ current group identifier12071208Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.12091210[More info.](windows.md#uid-and-gid)12111212### options.argv012131214_Type:_ `string`\1215_Default:_ file being executed12161217Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.12181219### options.windowsHide12201221_Type:_ `boolean`\1222_Default:_ `true`12231224On Windows, do not create a new console window.12251226[More info.](windows.md#console-window)12271228### options.windowsVerbatimArguments12291230_Type:_ `boolean`\1231_Default:_ `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwise12321233If `false`, escapes the command arguments on Windows.1234

Improve documentation for `windowsVerbatimArguments` (#1149)ehmickybefore adoptionc4cb62a

line 1235why, one step back
1235[More info.](windows.md#escaping)

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 1236–1270why, one step back
1236
1237## Verbose function12381239_Type_: `(string, VerboseObject) => string | undefined`12401241Function passed to the [`verbose`](#optionsverbose) option to customize logging.12421243[More info.](debugging.md#custom-logging)12441245### Verbose object12461247_Type_: `VerboseObject` or `SyncVerboseObject`12481249Subprocess event object, for logging purpose, using the [`verbose`](#optionsverbose) option.12501251#### verboseObject.type12521253_Type_: `string`12541255Event type. This can be:1256- `'command'`: subprocess start1257- `'output'`: `stdout`/`stderr` [output](output.md#stdout-and-stderr)1258- `'ipc'`: IPC [output](ipc.md#retrieve-all-messages)1259- `'error'`: subprocess [failure](errors.md#subprocess-failure)1260- `'duration'`: subprocess success or failure12611262#### verboseObject.message12631264_Type_: `string`12651266Depending on [`verboseObject.type`](#verboseobjecttype), this is:1267- `'command'`: the [`result.escapedCommand`](#resultescapedcommand)1268- `'output'`: one line from [`result.stdout`](#resultstdout) or [`result.stderr`](#resultstderr)1269- `'ipc'`: one IPC message from [`result.ipcOutput`](#resultipcoutput)1270- `'error'`: the [`error.shortMessage`](#errorshortmessage)

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

line 1271why, one step back
1271- `'duration'`: the [`result.durationMs`](#resultdurationms), formatted as `(done in 29ms)`

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 1272–1312why, one step back
1272
1273#### verboseObject.escapedCommand12741275_Type_: `string`12761277The file and [arguments](input.md#command-arguments) that were run. This is the same as [`result.escapedCommand`](#resultescapedcommand).12781279#### verboseObject.options12801281_Type_: [`Options`](#options-1) or [`SyncOptions`](#options-1)12821283The [options](#options-1) passed to the subprocess.12841285#### verboseObject.commandId12861287_Type_: `string`12881289Serial number identifying the subprocess within the current process. It is incremented from `'0'`.12901291This is helpful when multiple subprocesses are running at the same time.12921293This is similar to a [PID](https://en.wikipedia.org/wiki/Process_identifier) except it has no maximum limit, which means it never repeats. Also, it is usually shorter.12941295#### verboseObject.timestamp12961297_Type_: `Date`12981299Event date/time.13001301#### verboseObject.result13021303_Type_: [`Result`](#result), [`SyncResult`](#result) or `undefined`13041305Subprocess [result](#result).13061307This is `undefined` if [`verboseObject.type`](#verboseobjecttype) is `'command'`, `'output'` or `'ipc'`.13081309#### verboseObject.piped13101311_Type_: `boolean`1312

Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a

line 1313why, one step back
1313Whether this subprocess is the destination of another subprocess' [`pipe()`](#subprocesspipefile-arguments-options) method. This is `true` when it was spawned using the [template string](pipe.md#template-string-syntax) or [array](pipe.md#array-syntax) syntax, `false` otherwise.

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

lines 1314–1352why, one step back
1314
1315## Transform options13161317A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.13181319A transform is either a [generator function](#transformoptionstransform) or a plain object with the following members.13201321[More info.](transform.md)13221323### transformOptions.transform13241325_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`13261327Map or [filter](transform.md#filtering) the [input](input.md) or [output](output.md) of the subprocess.13281329More info [here](transform.md#summary) and [there](transform.md#sharing-state).13301331### transformOptions.final13321333_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`13341335Create additional lines after the last one.13361337[More info.](transform.md#finalizing)13381339### transformOptions.binary13401341_Type:_ `boolean`\1342_Default:_ `false`13431344If `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.13451346[More info.](binary.md#transforms)13471348### transformOptions.preserveNewlines13491350_Type:_ `boolean`\1351_Default:_ `false`1352

Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8

line 1353why, one step back
1353If `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produce a single line.

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

lines 1354–1369why, one step back
1354
1355[More info.](lines.md#transforms)13561357### transformOptions.objectMode13581359_Type:_ `boolean`\1360_Default:_ `false`13611362If `true`, allow [`transformOptions.transform`](#transformoptionstransform) and [`transformOptions.final`](#transformoptionsfinal) to return any type, not just `string` or `Uint8Array`.13631364[More info.](transform.md#object-mode)13651366<hr>13671368[**Previous**: 🔍 Differences with Bash and zx](bash.md)\1369[**Top**: Table of contents](../readme.md#documentation)