api.md
This file
Path
docs/api.md
1,309 lines · 51.3 KiB · Markdown
Last changed by
Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
History of this fileTake it
Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1–8why, one step back1<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 reference8Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 9why, one step back9This 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.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 10–16why, one step back1011## Methods1213### execa(file, arguments?, options?)1415`file`: `string | URL`\16`arguments`: `string[]`\Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 17why, one step back17`options`: [`Options`](#options-1)\Rename some types (#1009)ehmickybefore adoption2ef9186
line 18why, one step back18_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 19–23why, one step back1920Executes a command using `file ...arguments`.2122More info on the [syntax](execution.md#array-syntax) and [escaping](escaping.md#array-syntax).23Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 24why, one step back24### $(file, arguments?, options?)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 25why, one step back25Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 26–28why, one step back26`file`: `string | URL`\27`arguments`: `string[]`\28`options`: [`Options`](#options-1)\Rename some types (#1009)ehmickybefore adoption2ef9186
line 29why, one step back29_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 30why, one step back30Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 31why, one step back31Same as [`execa()`](#execafile-arguments-options) but using [script-friendly default options](scripts.md#script-files).Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 32why, one step back32Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 33why, one step back33This is the preferred method when executing multiple commands in a script file.Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 34why, one step back34Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 35why, one step back35[More info.](scripts.md)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 36why, one step back36Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 37why, one step back37### execaNode(scriptPath, arguments?, options?)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 38why, one step back38Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 39–42why, one step back39`scriptPath`: `string | URL`\40`arguments`: `string[]`\41`options`: [`Options`](#options-1)\42_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 43why, one step back43Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 44–45why, one step back44Same as [`execa()`](#execafile-arguments-options) but using the [`node: true`](#optionsnode) option.45Executes a Node.js file using `node scriptPath ...arguments`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 46why, one step back46Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 47–50why, one step back47This is the preferred method when executing Node.js files.4849[More info.](node.md)50Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 51why, one step back51### execaSync(file, arguments?, options?)Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 52–53why, one step back52### $.sync(file, arguments?, options?)53### $.s(file, arguments?, options?)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 54why, one step back54Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 55–57why, one step back55`file`: `string | URL`\56`arguments`: `string[]`\57`options`: [`SyncOptions`](#options-1)\Rename some types (#1009)ehmickybefore adoption2ef9186
line 58why, one step back58_Returns_: [`SyncResult`](#return-value)Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 59why, one step back59Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 60why, one step back60Same as [`execa()`](#execafile-arguments-options) and [`$`](#file-arguments-options) but synchronous.Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 61why, one step back61Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 62why, one step back62Returns a subprocess [`result`](#result) or throws an [`error`](#execasyncerror). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available.Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 63why, one step back63Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 64–65why, one step back64Those methods are discouraged as they hold the CPU and lack multiple features.65Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 66–67why, one step back66[More info.](execution.md#synchronous-execution)67Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 68–73why, one step back68### execa\`command\`69### $\`command\`70### execaNode\`command\`71### execaSync\`command\`72### $.sync\`command\`73### $.s\`command\`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 74why, one step back74Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 75–76why, one step back75`command`: `string`\76_Returns_: [`ResultPromise`](#return-value), [`SyncResult`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 77why, one step back77Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 78why, one step back78Same 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`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 79why, one step back79Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 80why, one step back80More info on the [syntax](execution.md#template-string-syntax) and [escaping](escaping.md#template-string-syntax).Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 81why, one step back81Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 82–87why, one step back82### execa(options)\`command\`83### $(options)\`command\`84### execaNode(options)\`command\`85### execaSync(options)\`command\`86### $.sync(options)\`command\`87### $.s(options)\`command\`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 88why, one step back88Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 89–91why, one step back89`command`: `string`\90`options`: [`Options`](#options-1), [`SyncOptions`](#options-1)\91_Returns_: [`ResultPromise`](#return-value), [`SyncResult`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 92why, one step back92Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 93why, one step back93Same as [```execa`command` ```](#execacommand) but with [options](#options-1).Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 94why, one step back94Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 95why, one step back95[More info.](execution.md#template-string-syntax)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 96why, one step back96Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 97–102why, one step back97### execa(options)98### $(options)99### execaNode(options)100### execaSync(options)101### $.sync(options)102### $.s(options)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 103why, one step back103Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
lines 104–105why, one step back104`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)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 106why, one step back106Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 107why, one step back107Returns a new instance of those methods but with different default [`options`](#options-1). Consecutive calls are merged to previous ones.Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 108why, one step back108Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 109why, one step back109[More info.](execution.md#globalshared-options)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 110why, one step back110Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3
line 111why, one step back111### parseCommandString(command)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 112–113why, one step back112113`command`: `string`\Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3
line 114why, one step back114_Returns_: `string[]`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 115why, one step back115Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3
line 116why, one step back116Split 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 117–119why, one step back117118[More info.](escaping.md#user-defined-input)119Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 120why, one step back120### sendMessage(message, sendMessageOptions?)Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 121–122why, one step back121122`message`: [`Message`](ipc.md#message-type)\Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 123why, one step back123`sendMessageOptions`: [`SendMessageOptions`](#sendmessageoptions)\Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 124–131why, one step back124_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)131Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
lines 132–144why, one step back132#### sendMessageOptions133134_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)144Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
line 145why, one step back145### getOneMessage(getOneMessageOptions?)Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 146why, one step back146Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 147why, one step back147`getOneMessageOptions`: [`GetOneMessageOptions`](#getonemessageoptions)\Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 148–155why, one step back148_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)155Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
lines 156–167why, one step back156#### getOneMessageOptions157158_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)167Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
line 168why, one step back168#### getOneMessageOptions.referenceAdd promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 169why, one step back169Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
lines 170–179why, one step back170_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 back180_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)187Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
lines 188–200why, one step back188#### getEachMessageOptions189190_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)200Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
lines 201–210why, one step back201### 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)210Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 211why, one step back211## Return valueMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 212why, one step back212Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
lines 213–214why, one step back213_TypeScript:_ [`ResultPromise`](typescript.md)\214_Type:_ `Promise<object> | Subprocess`Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 215why, one step back215Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 216why, one step back216The return value of all [asynchronous methods](#methods) is both:Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
lines 217–218why, one step back217- the [subprocess](#subprocess).218- 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 219–221why, one step back219220[More info.](execution.md#subprocess)221Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
lines 222–223why, one step back222## Subprocess223Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 224why, one step back224_TypeScript:_ [`Subprocess`](typescript.md)Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
lines 225–227why, one step back225226[`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following methods and properties.227Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 228–248why, one step back228### subprocess\[Symbol.asyncIterator\]()229230_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)231232Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.233234[More info.](lines.md#progressive-splitting)235236### subprocess.iterable(readableOptions?)237238`readableOptions`: [`ReadableOptions`](#readableoptions)\239_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)240241Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.242243[More info.](lines.md#progressive-splitting)244245### subprocess.pipe(file, arguments?, options?)246247`file`: `string | URL`\248`arguments`: `string[]`\Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 249why, one step back249`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 250–253why, one step back250_Returns_: [`Promise<Result>`](#result)251252[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.253Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 254why, one step back254This 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.Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 255why, one step back255Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 256–257why, one step back256Like 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.257Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 258–263why, one step back258[More info.](pipe.md#array-syntax)259260### subprocess.pipe\`command\`261### subprocess.pipe(options)\`command\`262263`command`: `string`\Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 264why, one step back264`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 265–266why, one step back265_Returns_: [`Promise<Result>`](#result)266Fix broken Markdown links (#1119)ehmickybefore adoption8572eb1
line 267why, one step back267Like [`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).Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 268–272why, one step back268269[More info.](pipe.md#template-string-syntax)270271### subprocess.pipe(secondSubprocess, pipeOptions?)272Rename some types (#1009)ehmickybefore adoption2ef9186
line 273why, one step back273`secondSubprocess`: [`ResultPromise`](#return-value)\Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 274–276why, one step back274`pipeOptions`: [`PipeOptions`](#pipeoptions)\275_Returns_: [`Promise<Result>`](#result)276Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 277why, one step back277Like [`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 278–282why, one step back278279[More info.](pipe.md#advanced-syntax)280281#### pipeOptions282Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 283why, one step back283_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 284–286why, one step back284285#### pipeOptions.from286Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 287–288why, one step back287_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\288_Default:_ `"stdout"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 289–297why, one step back289290Which stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.291292`"all"` pipes both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.293294[More info.](pipe.md#source-file-descriptor)295296#### pipeOptions.to297Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 298–299why, one step back298_Type:_ `"stdin" | "fd3" | "fd4" | ...`\299_Default:_ `"stdin"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 300–306why, one step back300301Which [stream](#subprocessstdin) to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.302303[More info.](pipe.md#destination-file-descriptor)304305#### pipeOptions.unpipeSignal306Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 307why, one step back307_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 308–319why, one step back308309Unpipe the subprocess when the signal aborts.310311[More info.](pipe.md#unpipe)312313### subprocess.kill(signal, error?)314### subprocess.kill(error?)315316`signal`: `string | number`\317`error`: `Error`\318_Returns_: `boolean`319Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 320why, one step back320Sends 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 321–329why, one step back321322This returns `false` when the signal could not be sent, for example when the subprocess has already exited.323324When 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).325326[More info.](termination.md)327328### subprocess.pid329Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 330why, one step back330_Type:_ `number | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 331–337why, one step back331332Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).333334This is `undefined` if the subprocess failed to spawn.335336[More info.](termination.md#inter-process-termination)337Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 338why, one step back338### subprocess.sendMessage(message, sendMessageOptions)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 339why, one step back339Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 340why, one step back340`message`: [`Message`](ipc.md#message-type)\Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 341why, one step back341`sendMessageOptions`: [`SendMessageOptions`](#sendmessageoptions)\Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 342why, one step back342_Returns_: `Promise<void>`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 343why, one step back343Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 344why, one step back344Send a `message` to the subprocess.Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 345why, one step back345Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 346why, one step back346This 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 347–349why, one step back347348[More info.](ipc.md#exchanging-messages)349Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
line 350why, one step back350### subprocess.getOneMessage(getOneMessageOptions?)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 351why, one step back351Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 352why, one step back352`getOneMessageOptions`: [`GetOneMessageOptions`](#getonemessageoptions)\Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 353why, one step back353_Returns_: [`Promise<Message>`](ipc.md#message-type)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 354why, one step back354Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 355why, one step back355Receive a single `message` from the subprocess.Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 356why, one step back356Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 357why, one step back357This 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 358–360why, one step back358359[More info.](ipc.md#exchanging-messages)360Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
line 361why, one step back361### subprocess.getEachMessage(getEachMessageOptions?)Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 362why, one step back362Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
line 363why, one step back363`getEachMessageOptions`: [`GetEachMessageOptions`](#geteachmessageoptions)\Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 364–371why, one step back364_Returns_: [`AsyncIterable<Message>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)365366Iterate over each `message` from the subprocess.367368This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.369370[More info.](ipc.md#listening-to-messages)371Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 372–373why, one step back372### subprocess.stdin373Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 374why, one step back374_Type:_ [`Writable | null`](https://nodejs.org/api/stream.html#class-streamwritable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 375–383why, one step back375376The subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.377378This 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).379380[More info.](streams.md#manual-streaming)381382### subprocess.stdout383Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 384why, one step back384_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 385–393why, one step back385386The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.387388This 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`.389390[More info.](streams.md#manual-streaming)391392### subprocess.stderr393Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 394why, one step back394_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 395–403why, one step back395396The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.397398This 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`.399400[More info.](streams.md#manual-streaming)401402### subprocess.all403Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 404why, one step back404_Type:_ [`Readable | undefined`](https://nodejs.org/api/stream.html#class-streamreadable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 405–415why, one step back405406Stream combining/interleaving [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).407408This requires the [`all`](#optionsall) option to be `true`.409410This 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`.411412More info on [interleaving](output.md#interleaved-output) and [streaming](streams.md#manual-streaming).413414### subprocess.stdio415Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 416why, one step back416_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 417–434why, one step back417418The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.419420Each 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`.421422[More info.](streams.md#manual-streaming)423424### subprocess.readable(readableOptions?)425426`readableOptions`: [`ReadableOptions`](#readableoptions)\427_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream428429Converts the subprocess to a readable stream.430431[More info.](streams.md#converting-a-subprocess-to-a-stream)432433#### readableOptions434Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 435why, one step back435_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 436–438why, one step back436437#### readableOptions.from438Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 439–440why, one step back439_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\440_Default:_ `"stdout"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 441–449why, one step back441442Which stream to read from the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.443444`"all"` reads both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.445446[More info.](streams.md#different-file-descriptor)447448#### readableOptions.binary449Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 450–451why, one step back450_Type:_ `boolean`\451_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 452–462why, one step back452453If `false`, iterates over lines. Each line is a string.454455If `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)).456457This is always `true` when the [`encoding`](#optionsencoding) option is binary.458459More info for [iterables](binary.md#iterable) and [streams](binary.md#streams).460461#### readableOptions.preserveNewlines462Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 463–464why, one step back463_Type:_ `boolean`\464_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 465–480why, one step back465466If both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.467468[More info.](lines.md#iterable)469470### subprocess.writable(writableOptions?)471472`writableOptions`: [`WritableOptions`](#writableoptions)\473_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream474475Converts the subprocess to a writable stream.476477[More info.](streams.md#converting-a-subprocess-to-a-stream)478479#### writableOptions480Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 481why, one step back481_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 482–484why, one step back482483#### writableOptions.to484Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 485–486why, one step back485_Type:_ `"stdin" | "fd3" | "fd4" | ...`\486_Default:_ `"stdin"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 487–502why, one step back487488Which [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.489490[More info.](streams.md#different-file-descriptor)491492### subprocess.duplex(duplexOptions?)493494`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\495_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream496497Converts the subprocess to a duplex stream.498499[More info.](streams.md#converting-a-subprocess-to-a-stream)500501## Result502Improve documentation of signal handling (#1105)ehmickybefore adoption01a4b42
line 503why, one step back503_TypeScript:_ [`Result`](typescript.md) or [`SyncResult`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 504why, one step back504_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 505why, one step back505Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 506why, one step back506[Result](execution.md#result) of a subprocess successful execution.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 507–511why, one step back507508When the subprocess [fails](errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.509510### result.stdout511Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 512why, one step back512_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 513–523why, one step back513514The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).515516This 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`.517518This 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).519520[More info.](output.md#stdout-and-stderr)521522### result.stderr523Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 524why, one step back524_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 525–535why, one step back525526The output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).527528This 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`.529530This 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).531532[More info.](output.md#stdout-and-stderr)533534### result.all535Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 536why, one step back536_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 537–549why, one step back537538The output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) interleaved.539540This requires the [`all`](#optionsall) option to be `true`.541542This 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`.543544This 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).545546[More info.](output.md#interleaved-output)547548### result.stdio549Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 550why, one step back550_Type:_ `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 551–559why, one step back551552The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).553554Items 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`.555556Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).557558[More info.](output.md#additional-file-descriptors)559Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 560why, one step back560### result.ipcOutputAdd `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de
line 561why, one step back561Fix type of `result.ipc` (#1071)ehmickybefore adoption69152ec
line 562why, one step back562_Type_: [`Message[]`](ipc.md#message-type)Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de
line 563why, one step back563Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 564why, one step back564All the messages [sent by the subprocess](#sendmessagemessage-sendmessageoptions) to the current process.Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de
lines 565–569why, one step back565566This is empty unless the [`ipc`](#optionsipc) option is `true`. Also, this is empty if the [`buffer`](#optionsbuffer) option is `false`.567568[More info.](ipc.md#retrieve-all-messages)569Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 570–571why, one step back570### result.pipedFrom571Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 572why, one step back572_Type:_ [`Array<Result | ExecaError>`](#result)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 573–581why, one step back573574[Results](#result) of the other subprocesses that were piped into this subprocess.575576This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.577578[More info.](pipe.md#result)579580### result.command581Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 582why, one step back582_Type:_ `string`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 583–589why, one step back583584The file and [arguments](input.md#command-arguments) that were run.585586[More info.](debugging.md#command)587588### result.escapedCommand589Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 590why, one step back590_Type:_ `string`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 591–597why, one step back591592Same as [`command`](#resultcommand) but escaped.593594[More info.](debugging.md#command)595596### result.cwd597Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 598why, one step back598_Type:_ `string`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 599–605why, one step back599600The [current directory](#optionscwd) in which the command was run.601602[More info.](environment.md#current-directory)603604### result.durationMs605Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 606why, one step back606_Type:_ `number`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 607–613why, one step back607608Duration of the subprocess, in milliseconds.609610[More info.](debugging.md#duration)611612### result.failed613Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 614why, one step back614_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 615–617why, one step back615616Whether the subprocess failed to run.617Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 618–619why, one step back618When this is `true`, the result is an [`ExecaError`](#execaerror) instance with additional error-related properties.619Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 620–621why, one step back620[More info.](errors.md#subprocess-failure)621Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 622–623why, one step back622## ExecaError623## ExecaSyncErrorMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 624why, one step back624Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 625why, one step back625_Type:_ `Error`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 626–636why, one step back626627Result of a subprocess [failed execution](errors.md#subprocess-failure).628629This error is thrown as an exception. If the [`reject`](#optionsreject) option is false, it is returned instead.630631This has the same shape as [successful results](#result), with the following additional properties.632633[More info.](errors.md)634635### error.message636Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 637why, one step back637_Type:_ `string`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 638–644why, one step back638639Error message when the subprocess [failed](errors.md#subprocess-failure) to run.640641[More info.](errors.md#error-message)642643### error.shortMessage644Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 645why, one step back645_Type:_ `string`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 646–652why, one step back646647This is the same as [`error.message`](#errormessage) except it does not include the subprocess [output](output.md).648649[More info.](errors.md#error-message)650651### error.originalMessage652Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 653why, one step back653_Type:_ `string | undefined`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 654–660why, one step back654655Original error message. This is the same as [`error.message`](#errormessage) excluding the subprocess [output](output.md) and some additional information added by Execa.656657[More info.](errors.md#error-message)658659### error.cause660Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 661why, one step back661_Type:_ `unknown | undefined`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 662–670why, one step back662663Underlying error, if there is one. For example, this is set by [`subprocess.kill(error)`](#subprocesskillerror).664665This is usually an `Error` instance.666667[More info.](termination.md#error-message-and-stack-trace)668669### error.code670Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 671why, one step back671_Type:_ `string | undefined`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 672–676why, one step back672673Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.674675### error.timedOut676Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 677why, one step back677_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 678–682why, one step back678679Whether the subprocess timed out due to the [`timeout`](#optionstimeout) option.680681[More info.](termination.md#timeout)682Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 683why, one step back683### error.isCanceledMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 684why, one step back684Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 685why, one step back685_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 686–690why, one step back686687Whether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.688689[More info.](termination.md#canceling)690Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
lines 691–698why, one step back691### error.isGracefullyCanceled692693_Type:_ `boolean`694695Whether the subprocess was canceled using both the [`cancelSignal`](#optionscancelsignal) and the [`gracefulCancel`](#optionsgracefulcancel) options.696697[More info.](termination.md#graceful-termination)698Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 699why, one step back699### error.isMaxBufferMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 700why, one step back700Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 701why, one step back701_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 702–706why, one step back702703Whether the subprocess failed because its output was larger than the [`maxBuffer`](#optionsmaxbuffer) option.704705[More info.](output.md#big-output)706Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 707why, one step back707### error.isTerminatedMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 708why, one step back708Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 709why, one step back709_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 710–716why, one step back710711Whether the subprocess was terminated by a [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) sent by either:712- The current process.713- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).714715[More info.](termination.md#signal-name-and-description)716Add `error.isForcefullyTerminated` (#1111)ehmickybefore adoptione69985d
lines 717–724why, one step back717### error.isForcefullyTerminated718719_Type:_ `boolean`720721Whether the subprocess was terminated by the [`SIGKILL`](termination.md#sigkill) signal sent by the [`forceKillAfterDelay`](#optionsforcekillafterdelay) option.722723[More info.](termination.md#forceful-termination)724Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 725why, one step back725### error.exitCodeMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 726why, one step back726Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 727why, one step back727_Type:_ `number | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 728–730why, one step back728729The numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.730Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 731why, one step back731This 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 732–734why, one step back732733[More info.](errors.md#exit-code)734Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 735why, one step back735### error.signalMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 736why, one step back736Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 737why, one step back737_Type:_ `string | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 738–746why, one step back738739The name of the [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) that terminated the subprocess, sent by either:740- The current process.741- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).742743If a signal terminated the subprocess, this property is defined and included in the [error message](#errormessage). Otherwise it is `undefined`.744745[More info.](termination.md#signal-name-and-description)746Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 747why, one step back747### error.signalDescriptionMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 748why, one step back748Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 749why, one step back749_Type:_ `string | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 750–758why, one step back750751A human-friendly description of the [signal](termination.md#signal-termination) that was used to terminate the subprocess.752753If 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.754755[More info.](termination.md#signal-name-and-description)756757## Options758Fix a typo (#1153)Reuben Thomasbefore adoption3fc8049
line 759why, one step back759_TypeScript:_ [`Options`](typescript.md) or [`SyncOptions`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 760why, one step back760_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 761–767why, one step back761762This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).763764The 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).765766### options.preferLocal767Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 768–769why, one step back768_Type:_ `boolean`\769_Default:_ `true` with [`$`](#file-arguments-options), `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 770–776why, one step back770771Prefer locally installed binaries when looking for a binary to execute.772773[More info.](environment.md#local-binaries)774775### options.localDir776Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 777–778why, one step back777_Type:_ `string | URL`\778_Default:_ [`cwd`](#optionscwd) optionMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 779–785why, one step back779780Preferred path to find locally installed binaries, when using the [`preferLocal`](#optionspreferlocal) option.781782[More info.](environment.md#local-binaries)783784### options.node785Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 786–787why, one step back786_Type:_ `boolean`\787_Default:_ `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 788–790why, one step back788789If `true`, runs with Node.js. The first argument must be a Node.js file.790Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5
lines 791–792why, one step back791The 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.792Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 793–796why, one step back793[More info.](node.md)794795### options.nodeOptions796Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 797why, one step back797_Type:_ `string[]`\Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5
line 798why, one step back798_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 799–807why, one step back799800List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#optionsnodepath).801802Requires the [`node`](#optionsnode) option to be `true`.803804[More info.](node.md#nodejs-cli-flags)805806### options.nodePath807Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 808–809why, one step back808_Type:_ `string | URL`\809_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 810–818why, one step back810811Path to the Node.js executable.812813Requires the [`node`](#optionsnode) option to be `true`.814815[More info.](node.md#nodejs-version)816817### options.shell818Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 819–820why, one step back819_Type:_ `boolean | string | URL`\820_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 821–831why, one step back821822If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).823824Uses [`/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.825826We [recommend against](shell.md#avoiding-shells) using this option.827828[More info.](shell.md)829830### options.cwd831Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 832–833why, one step back832_Type:_ `string | URL`\833_Default:_ `process.cwd()`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 834–842why, one step back834835Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.836837This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.838839[More info.](environment.md#current-directory)840841### options.env842Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 843–844why, one step back843_Type:_ `object`\844_Default:_ [`process.env`](https://nodejs.org/api/process.html#processenv)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 845–853why, one step back845846[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).847848Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).849850[More info.](input.md#environment-variables)851852### options.extendEnv853Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 854–855why, one step back854_Type:_ `boolean`\855_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 856–863why, one step back856857If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).858If `false`, only the `env` option is used, not `process.env`.859860[More info.](input.md#environment-variables)861862### options.input863Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 864why, one step back864_Type:_ `string | Uint8Array | stream.Readable`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 865–873why, one step back865866Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).867868See also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options.869870[More info.](input.md#string-input)871872### options.inputFile873Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 874why, one step back874_Type:_ `string | URL`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 875–883why, one step back875876Use a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).877878See also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options.879880[More info.](input.md#file-input)881882### options.stdin883Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 884why, one step back884_TypeScript:_ [`StdinOption`](typescript.md) or [`StdinSyncOption`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 885–886why, one step back885_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)\886_Default:_ `'inherit'` with [`$`](#file-arguments-options), `'pipe'` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 887–895why, one step back887888How 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).889890This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.891892More info on [available values](input.md), [streaming](streams.md) and [transforms](transform.md).893894### options.stdout895Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 896why, one step back896_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 897–898why, one step back897_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)\898_Default:_ `pipe`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 899–907why, one step back899900How 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).901902This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.903904More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).905906### options.stderr907Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 908why, one step back908_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 909–910why, one step back909_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)\910_Default:_ `pipe`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 911–919why, one step back911912How 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).913914This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.915916More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).917918### options.stdio919Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 920why, one step back920_TypeScript:_ [`Options['stdio']`](typescript.md) or [`SyncOptions['stdio']`](typescript.md)\Generalize `{value, input}` to any direction-ambiguous stdio value (#1249)Sindre Sorhusbefore adoption9fbf5ba
line 921why, one step back921_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
line 922why, one step back922_Default:_ `pipe`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 923–927why, one step back923924Like 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'}`.925926A single string can be used [as a shortcut](output.md#shortcut).927Generalize `{value, input}` to any direction-ambiguous stdio value (#1249)Sindre Sorhusbefore adoption9fbf5ba
line 928why, one step back928The 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}`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 929–933why, one step back929930More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).931932### options.all933Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 934–935why, one step back934_Type:_ `boolean`\935_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 936–942why, one step back936937Add a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.938939[More info.](output.md#interleaved-output)940941### options.encoding942Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 943–944why, one step back943_Type:_ `'utf8' | 'utf16le' | 'buffer' | 'hex' | 'base64' | 'base64url' | 'latin1' | 'ascii'`\944_Default:_ `'utf8'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 945–949why, one step back945946If 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).947948If it outputs binary data instead, this should be either:949- `'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 950why, one step back950- [`'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.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 951–957why, one step back951952The output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).953954[More info.](binary.md)955956### options.lines957Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 958–959why, one step back958_Type:_ `boolean`\959_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 960–970why, one step back960961Set [`result.stdout`](#resultstdout), [`result.stderr`](#resultstdout), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) as arrays of strings, splitting the subprocess' output into lines.962963This cannot be used if the [`encoding`](#optionsencoding) option is [binary](binary.md#binary-output).964965By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).966967[More info.](lines.md#simple-splitting)968969### options.stripFinalNewline970Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 971–972why, one step back971_Type:_ `boolean`\972_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 973–983why, one step back973974Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.975976If the [`lines`](#optionslines) option is true, this applies to each output line instead.977978By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).979980[More info.](lines.md#newlines)981982### options.maxBuffer983Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 984–985why, one step back984_Type:_ `number`\985_Default:_ `100_000_000`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 986–990why, one step back986987Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).988989By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).990Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
lines 991–992why, one step back991When reached, [`error.isMaxBuffer`](#errorismaxbuffer) becomes `true`.992Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 993–996why, one step back993[More info.](output.md#big-output)994995### options.buffer996Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 997–998why, one step back997_Type:_ `boolean`\998_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 999–1007why, one step back9991000When `buffer` is `false`, the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties are not set.10011002By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10031004[More info.](output.md#low-memory)10051006### options.ipc1007Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 1008why, one step back1008_Type:_ `boolean`\Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 1009why, one step back1009_Default:_ `true` if the [`node`](#optionsnode), [`ipcInput`](#optionsipcinput) or [`gracefulCancel`](#optionsgracefulcancel) option is set, `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 1010why, one step back1010Fix broken Markdown links (#1119)ehmickybefore adoption8572eb1
line 1011why, one step back1011Enables exchanging messages with the subprocess using [`subprocess.sendMessage(message)`](#subprocesssendmessagemessage-sendmessageoptions), [`subprocess.getOneMessage()`](#subprocessgetonemessagegetonemessageoptions) and [`subprocess.getEachMessage()`](#subprocessgeteachmessagegeteachmessageoptions).Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 1012why, one step back1012Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 1013–1014why, one step back1013The subprocess must be a Node.js file.1014Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1015–1018why, one step back1015[More info.](ipc.md)10161017### options.serialization1018Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1019–1020why, one step back1019_Type:_ `'json' | 'advanced'`\1020_Default:_ `'advanced'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1021–1024why, one step back10211022Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.10231024[More info.](ipc.md#message-type)Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 1025–1034why, one step back10251026### options.ipcInput10271028_Type_: [`Message`](ipc.md#message-type)10291030Sends an IPC message when the subprocess starts.10311032The subprocess must be a [Node.js file](#optionsnode). The value's [type](ipc.md#message-type) depends on the [`serialization`](#optionsserialization) option.10331034More 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 1035–1037why, one step back10351036### options.verbose1037Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 1038why, one step back1038_Type:_ `'none' | 'short' | 'full' | Function`\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 1039why, one step back1039_Default:_ `'none'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1040–1042why, one step back10401041If `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.1042Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 1043why, one step back1043If `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.Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 1044why, one step back1044Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 1045–1046why, one step back1045A [function](#verbose-function) can be passed to customize logging. Please see [this page](debugging.md#custom-logging) for more information.1046Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1047–1052why, one step back1047By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10481049[More info.](debugging.md#verbose-mode)10501051### options.reject1052Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1053–1054why, one step back1053_Type:_ `boolean`\1054_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 1055why, one step back1055Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 1056why, one step back1056Setting 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 1057–1061why, one step back10571058[More info.](errors.md#preventing-exceptions)10591060### options.timeout1061Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1062–1063why, one step back1062_Type:_ `number`\1063_Default:_ `0`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1064–1066why, one step back10641065If `timeout` is greater than `0`, the subprocess will be [terminated](#optionskillsignal) if it runs for longer than that amount of milliseconds.1066Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 1067why, one step back1067On timeout, [`error.timedOut`](#errortimedout) becomes `true`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1068–1072why, one step back10681069[More info.](termination.md#timeout)10701071### options.cancelSignal1072Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 1073why, one step back1073_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 1074why, one step back1074Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 1075why, one step back1075When 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 1076why, one step back1076Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 1077why, one step back1077When aborted, [`error.isCanceled`](#erroriscanceled) becomes `true`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1078–1079why, one step back10781079[More info.](termination.md#canceling)Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
lines 1080–1092why, one step back10801081### options.gracefulCancel10821083_Type:_ `boolean`\1084_Default:_: `false`10851086When 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.10871088The subprocess must be a [Node.js file](#optionsnode).10891090When aborted, [`error.isGracefullyCanceled`](#errorisgracefullycanceled) becomes `true`.10911092[More info.](termination.md#graceful-termination)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1093–1095why, one step back10931094### options.forceKillAfterDelay1095Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1096–1097why, one step back1096_Type:_ `number | false`\1097_Default:_ `5000`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1098–1099why, one step back10981099If 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 1100–1101why, one step back11001101When this happens, [`error.isForcefullyTerminated`](#errorisforcefullyterminated) becomes `true`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1102–1106why, one step back11021103[More info.](termination.md#forceful-termination)11041105### options.killSignal1106Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1107–1108why, one step back1107_Type:_ `string | number`\1108_Default:_ `'SIGTERM'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1109–1117why, one step back11091110Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.11111112This can be either a name (like [`'SIGTERM'`](termination.md#sigterm)) or a number (like `9`).11131114[More info.](termination.md#default-signal)11151116### options.detached1117Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1118–1119why, one step back1118_Type:_ `boolean`\1119_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1120–1126why, one step back11201121Run the subprocess independently from the current process.11221123[More info.](environment.md#background-subprocess)11241125### options.cleanup1126Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1127–1128why, one step back1127_Type:_ `boolean`\1128_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1129–1135why, one step back11291130Kill the subprocess when the current process exits.11311132[More info.](termination.md#current-process-exit)11331134### options.uid1135Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1136–1137why, one step back1136_Type:_ `number`\1137_Default:_ current user identifierMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1138–1144why, one step back11381139Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.11401141[More info.](windows.md#uid-and-gid)11421143### options.gid1144Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1145–1146why, one step back1145_Type:_ `number`\1146_Default:_ current group identifierMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1147–1153why, one step back11471148Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.11491150[More info.](windows.md#uid-and-gid)11511152### options.argv01153Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1154–1155why, one step back1154_Type:_ `string`\1155_Default:_ file being executedMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1156–1160why, one step back11561157Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.11581159### options.windowsHide1160Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1161–1162why, one step back1161_Type:_ `boolean`\1162_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1163–1169why, one step back11631164On Windows, do not create a new console window.11651166[More info.](windows.md#console-window)11671168### options.windowsVerbatimArguments1169Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1170–1171why, one step back1170_Type:_ `boolean`\1171_Default:_ `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1172–1174why, one step back11721173If `false`, escapes the command arguments on Windows.1174Improve documentation for `windowsVerbatimArguments` (#1149)ehmickybefore adoptionc4cb62a
line 1175why, one step back1175[More info.](windows.md#escaping)Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 1176–1253why, one step back11761177## Verbose function11781179_Type_: `(string, VerboseObject) => string | undefined`11801181Function passed to the [`verbose`](#optionsverbose) option to customize logging.11821183[More info.](debugging.md#custom-logging)11841185### Verbose object11861187_Type_: `VerboseObject` or `SyncVerboseObject`11881189Subprocess event object, for logging purpose, using the [`verbose`](#optionsverbose) option.11901191#### verboseObject.type11921193_Type_: `string`11941195Event type. This can be:1196- `'command'`: subprocess start1197- `'output'`: `stdout`/`stderr` [output](output.md#stdout-and-stderr)1198- `'ipc'`: IPC [output](ipc.md#retrieve-all-messages)1199- `'error'`: subprocess [failure](errors.md#subprocess-failure)1200- `'duration'`: subprocess success or failure12011202#### verboseObject.message12031204_Type_: `string`12051206Depending on [`verboseObject.type`](#verboseobjecttype), this is:1207- `'command'`: the [`result.escapedCommand`](#resultescapedcommand)1208- `'output'`: one line from [`result.stdout`](#resultstdout) or [`result.stderr`](#resultstderr)1209- `'ipc'`: one IPC message from [`result.ipcOutput`](#resultipcoutput)1210- `'error'`: the [`error.shortMessage`](#errorshortmessage)1211- `'duration'`: the [`result.durationMs`](#resultdurationms)12121213#### verboseObject.escapedCommand12141215_Type_: `string`12161217The file and [arguments](input.md#command-arguments) that were run. This is the same as [`result.escapedCommand`](#resultescapedcommand).12181219#### verboseObject.options12201221_Type_: [`Options`](#options-1) or [`SyncOptions`](#options-1)12221223The [options](#options-1) passed to the subprocess.12241225#### verboseObject.commandId12261227_Type_: `string`12281229Serial number identifying the subprocess within the current process. It is incremented from `'0'`.12301231This is helpful when multiple subprocesses are running at the same time.12321233This 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.12341235#### verboseObject.timestamp12361237_Type_: `Date`12381239Event date/time.12401241#### verboseObject.result12421243_Type_: [`Result`](#result), [`SyncResult`](#result) or `undefined`12441245Subprocess [result](#result).12461247This is `undefined` if [`verboseObject.type`](#verboseobjecttype) is `'command'`, `'output'` or `'ipc'`.12481249#### verboseObject.piped12501251_Type_: `boolean`12521253Whether another subprocess is [piped](pipe.md) into this subprocess. This is `false` when [`result.pipedFrom`](#resultfailed) is empty.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1254–1264why, one step back12541255## Transform options12561257A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.12581259A transform is either a [generator function](#transformoptionstransform) or a plain object with the following members.12601261[More info.](transform.md)12621263### transformOptions.transform1264Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 1265why, one step back1265_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1266–1272why, one step back12661267Map or [filter](transform.md#filtering) the [input](input.md) or [output](output.md) of the subprocess.12681269More info [here](transform.md#summary) and [there](transform.md#sharing-state).12701271### transformOptions.final1272Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 1273why, one step back1273_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1274–1280why, one step back12741275Create additional lines after the last one.12761277[More info.](transform.md#finalizing)12781279### transformOptions.binary1280Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1281–1282why, one step back1281_Type:_ `boolean`\1282_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1283–1289why, one step back12831284If `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.12851286[More info.](binary.md#transforms)12871288### transformOptions.preserveNewlines1289Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1290–1291why, one step back1290_Type:_ `boolean`\1291_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 1292why, one step back1292Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8
line 1293why, one step back1293If `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produce a single line.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1294–1298why, one step back12941295[More info.](lines.md#transforms)12961297### transformOptions.objectMode1298Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1299–1300why, one step back1299_Type:_ `boolean`\1300_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1301–1309why, one step back13011302If `true`, allow [`transformOptions.transform`](#transformoptionstransform) and [`transformOptions.final`](#transformoptionsfinal) to return any type, not just `string` or `Uint8Array`.13031304[More info.](transform.md#object-mode)13051306<hr>13071308[**Previous**: 🔍 Differences with Bash and zx](bash.md)\1309[**Top**: Table of contents](../readme.md#documentation)