api.md
This file
Path
docs/api.md
1,052 lines · 41.9 KiB · Markdown
Last changed by
Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
History of this fileTake it
Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1–17why, 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 reference89This lists all available [methods](#methods) and their [options](#options). This also describes the properties of the [subprocess](#subprocess), [result](#result) and [error](#execaerror) they return.1011## Methods1213### execa(file, arguments?, options?)1415`file`: `string | URL`\16`arguments`: `string[]`\17`options`: [`Options`](#options)\Rename some types (#1009)ehmickybefore adoption2ef9186
line 18why, one step back18_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 19–28why, one step back1920Executes a command using `file ...arguments`.2122More info on the [syntax](execution.md#array-syntax) and [escaping](escaping.md#array-syntax).2324### execa\`command\`25### execa(options)\`command\`2627`command`: `string`\28`options`: [`Options`](#options)\Rename some types (#1009)ehmickybefore adoption2ef9186
line 29why, one step back29_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 30–46why, one step back3031Executes a command. `command` is a [template string](execution.md#template-string-syntax) that includes both the `file` and its `arguments`.3233More info on the [syntax](execution.md#template-string-syntax) and [escaping](escaping.md#template-string-syntax).3435### execa(options)3637`options`: [`Options`](#options)\38_Returns_: [`execa`](#execafile-arguments-options)3940Returns a new instance of Execa but with different default [`options`](#options). Consecutive calls are merged to previous ones.4142[More info.](execution.md#globalshared-options)4344### execaSync(file, arguments?, options?)45### execaSync\`command\`46Rename some types (#1009)ehmickybefore adoption2ef9186
line 47why, one step back47_Returns_: [`SyncResult`](#return-value)Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 48why, one step back48Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 49–59why, one step back49Same as [`execa()`](#execafile-arguments-options) but synchronous.5051Returns or throws a subprocess [`result`](#result). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available.5253[More info.](execution.md#synchronous-execution)5455### $(file, arguments?, options?)5657`file`: `string | URL`\58`arguments`: `string[]`\59`options`: [`Options`](#options)\Rename some types (#1009)ehmickybefore adoption2ef9186
line 60why, one step back60_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 61–74why, one step back6162Same as [`execa()`](#execafile-arguments-options) but using [script-friendly default options](scripts.md#script-files).6364Just like `execa()`, this can use the [template string syntax](execution.md#template-string-syntax) or [bind options](execution.md#globalshared-options). It can also be [run synchronously](#execasyncfile-arguments-options) using `$.sync()` or `$.s()`.6566This is the preferred method when executing multiple commands in a script file.6768[More info.](scripts.md)6970### execaNode(scriptPath, arguments?, options?)7172`scriptPath`: `string | URL`\73`arguments`: `string[]`\74`options`: [`Options`](#options)\Rename some types (#1009)ehmickybefore adoption2ef9186
line 75why, one step back75_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 76–89why, one step back7677Same as [`execa()`](#execafile-arguments-options) but using the [`node: true`](#optionsnode) option.78Executes a Node.js file using `node scriptPath ...arguments`.7980Just like `execa()`, this can use the [template string syntax](execution.md#template-string-syntax) or [bind options](execution.md#globalshared-options).8182This is the preferred method when executing Node.js files.8384[More info.](node.md)8586### execaCommand(command, options?)8788`command`: `string`\89`options`: [`Options`](#options)\Rename some types (#1009)ehmickybefore adoption2ef9186
line 90why, one step back90_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 91–99why, one step back9192Executes a command. `command` is a string that includes both the `file` and its `arguments`.9394This is only intended for very specific cases, such as a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop). This should be avoided otherwise.9596Just like `execa()`, this can [bind options](execution.md#globalshared-options). It can also be [run synchronously](#execasyncfile-arguments-options) using `execaCommandSync()`.9798[More info.](escaping.md#user-defined-input)99Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 100why, one step back100## Return valueMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 101why, one step back101Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
lines 102–103why, one step back102_TypeScript:_ [`ResultPromise`](typescript.md)\103_Type:_ `Promise<object> | Subprocess`Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 104why, one step back104Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 105why, one step back105The return value of all [asynchronous methods](#methods) is both:Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
lines 106–107why, one step back106- the [subprocess](#subprocess).107- 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 108–110why, one step back108109[More info.](execution.md#subprocess)110Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
lines 111–112why, one step back111## Subprocess112Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 113why, one step back113_TypeScript:_ [`Subprocess`](typescript.md)Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
lines 114–116why, one step back114115[`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following methods and properties.116Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 117–159why, one step back117### subprocess\[Symbol.asyncIterator\]()118119_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)120121Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.122123[More info.](lines.md#progressive-splitting)124125### subprocess.iterable(readableOptions?)126127`readableOptions`: [`ReadableOptions`](#readableoptions)\128_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)129130Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.131132[More info.](lines.md#progressive-splitting)133134### subprocess.pipe(file, arguments?, options?)135136`file`: `string | URL`\137`arguments`: `string[]`\138`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\139_Returns_: [`Promise<Result>`](#result)140141[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.142143This follows the same syntax as [`execa(file, arguments?, options?)`](#execafile-arguments-options) except both [regular options](#options) and [pipe-specific options](#pipeoptions) can be specified.144145[More info.](pipe.md#array-syntax)146147### subprocess.pipe\`command\`148### subprocess.pipe(options)\`command\`149150`command`: `string`\151`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\152_Returns_: [`Promise<Result>`](#result)153154Like [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using a [`command` template string](scripts.md#piping-stdout-to-another-command) instead. This follows the same syntax as `execa` [template strings](execution.md#template-string-syntax).155156[More info.](pipe.md#template-string-syntax)157158### subprocess.pipe(secondSubprocess, pipeOptions?)159Rename some types (#1009)ehmickybefore adoption2ef9186
line 160why, one step back160`secondSubprocess`: [`ResultPromise`](#return-value)\Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 161–163why, one step back161`pipeOptions`: [`PipeOptions`](#pipeoptions)\162_Returns_: [`Promise<Result>`](#result)163Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 164why, one step back164Like [`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 165–169why, one step back165166[More info.](pipe.md#advanced-syntax)167168#### pipeOptions169Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 170why, one step back170_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 171–173why, one step back171172#### pipeOptions.from173Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 174–175why, one step back174_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\175_Default:_ `"stdout"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 176–184why, one step back176177Which stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.178179`"all"` pipes both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.180181[More info.](pipe.md#source-file-descriptor)182183#### pipeOptions.to184Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 185–186why, one step back185_Type:_ `"stdin" | "fd3" | "fd4" | ...`\186_Default:_ `"stdin"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 187–193why, one step back187188Which [stream](#subprocessstdin) to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.189190[More info.](pipe.md#destination-file-descriptor)191192#### pipeOptions.unpipeSignal193Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 194why, one step back194_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 195–206why, one step back195196Unpipe the subprocess when the signal aborts.197198[More info.](pipe.md#unpipe)199200### subprocess.kill(signal, error?)201### subprocess.kill(error?)202203`signal`: `string | number`\204`error`: `Error`\205_Returns_: `boolean`206Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 207why, one step back207Sends 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 208–216why, one step back208209This returns `false` when the signal could not be sent, for example when the subprocess has already exited.210211When 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).212213[More info.](termination.md)214215### subprocess.pid216Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 217why, one step back217_Type:_ `number | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 218–251why, one step back218219Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).220221This is `undefined` if the subprocess failed to spawn.222223[More info.](termination.md#inter-process-termination)224225### subprocess.send(message)226227`message`: `unknown`\228_Returns_: `boolean`229230Send a `message` to the subprocess. The type of `message` depends on the [`serialization`](#optionsserialization) option.231The subprocess receives it as a [`message` event](https://nodejs.org/api/process.html#event-message).232233This returns `true` on success.234235This requires the [`ipc`](#optionsipc) option to be `true`.236237[More info.](ipc.md#exchanging-messages)238239### subprocess.on('message', (message) => void)240241`message`: `unknown`242243Receives a `message` from the subprocess. The type of `message` depends on the [`serialization`](#optionsserialization) option.244The subprocess sends it using [`process.send(message)`](https://nodejs.org/api/process.html#processsendmessage-sendhandle-options-callback).245246This requires the [`ipc`](#optionsipc) option to be `true`.247248[More info.](ipc.md#exchanging-messages)249250### subprocess.stdin251Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 252why, one step back252_Type:_ [`Writable | null`](https://nodejs.org/api/stream.html#class-streamwritable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 253–261why, one step back253254The subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.255256This 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).257258[More info.](streams.md#manual-streaming)259260### subprocess.stdout261Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 262why, one step back262_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 263–271why, one step back263264The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.265266This 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`.267268[More info.](streams.md#manual-streaming)269270### subprocess.stderr271Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 272why, one step back272_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 273–281why, one step back273274The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.275276This 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`.277278[More info.](streams.md#manual-streaming)279280### subprocess.all281Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 282why, one step back282_Type:_ [`Readable | undefined`](https://nodejs.org/api/stream.html#class-streamreadable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 283–293why, one step back283284Stream combining/interleaving [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).285286This requires the [`all`](#optionsall) option to be `true`.287288This 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`.289290More info on [interleaving](output.md#interleaved-output) and [streaming](streams.md#manual-streaming).291292### subprocess.stdio293Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 294why, one step back294_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 295–312why, one step back295296The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.297298Each 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`.299300[More info.](streams.md#manual-streaming)301302### subprocess.readable(readableOptions?)303304`readableOptions`: [`ReadableOptions`](#readableoptions)\305_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream306307Converts the subprocess to a readable stream.308309[More info.](streams.md#converting-a-subprocess-to-a-stream)310311#### readableOptions312Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 313why, one step back313_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 314–316why, one step back314315#### readableOptions.from316Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 317–318why, one step back317_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\318_Default:_ `"stdout"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 319–327why, one step back319320Which stream to read from the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.321322`"all"` reads both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.323324[More info.](streams.md#different-file-descriptor)325326#### readableOptions.binary327Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 328–329why, one step back328_Type:_ `boolean`\329_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 330–340why, one step back330331If `false`, iterates over lines. Each line is a string.332333If `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)).334335This is always `true` when the [`encoding`](#optionsencoding) option is binary.336337More info for [iterables](binary.md#iterable) and [streams](binary.md#streams).338339#### readableOptions.preserveNewlines340Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 341–342why, one step back341_Type:_ `boolean`\342_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 343–358why, one step back343344If both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.345346[More info.](lines.md#iterable)347348### subprocess.writable(writableOptions?)349350`writableOptions`: [`WritableOptions`](#writableoptions)\351_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream352353Converts the subprocess to a writable stream.354355[More info.](streams.md#converting-a-subprocess-to-a-stream)356357#### writableOptions358Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 359why, one step back359_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 360–362why, one step back360361#### writableOptions.to362Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 363–364why, one step back363_Type:_ `"stdin" | "fd3" | "fd4" | ...`\364_Default:_ `"stdin"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 365–380why, one step back365366Which [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.367368[More info.](streams.md#different-file-descriptor)369370### subprocess.duplex(duplexOptions?)371372`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\373_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream374375Converts the subprocess to a duplex stream.376377[More info.](streams.md#converting-a-subprocess-to-a-stream)378379## Result380Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 381why, one step back381_TypeScript:_ [`Result`](typescript.md) or [`SyncResult`](typescript.md\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 382why, one step back382_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 383why, one step back383Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 384why, one step back384[Result](execution.md#result) of a subprocess successful execution.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 385–389why, one step back385386When the subprocess [fails](errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.387388### result.stdout389Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 390why, one step back390_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 391–401why, one step back391392The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).393394This 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`.395396This 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).397398[More info.](output.md#stdout-and-stderr)399400### result.stderr401Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 402why, one step back402_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 403–413why, one step back403404The output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).405406This 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`.407408This 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).409410[More info.](output.md#stdout-and-stderr)411412### result.all413Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 414why, one step back414_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 415–427why, one step back415416The output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) interleaved.417418This requires the [`all`](#optionsall) option to be `true`.419420This 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`.421422This 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).423424[More info.](output.md#interleaved-output)425426### result.stdio427Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 428why, one step back428_Type:_ `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 429–439why, one step back429430The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).431432Items 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`.433434Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).435436[More info.](output.md#additional-file-descriptors)437438### result.pipedFrom439Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 440why, one step back440_Type:_ [`Array<Result | ExecaError>`](#result)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 441–449why, one step back441442[Results](#result) of the other subprocesses that were piped into this subprocess.443444This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.445446[More info.](pipe.md#result)447448### result.command449Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 450why, one step back450_Type:_ `string`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 451–457why, one step back451452The file and [arguments](input.md#command-arguments) that were run.453454[More info.](debugging.md#command)455456### result.escapedCommand457Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 458why, one step back458_Type:_ `string`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 459–465why, one step back459460Same as [`command`](#resultcommand) but escaped.461462[More info.](debugging.md#command)463464### result.cwd465Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 466why, one step back466_Type:_ `string`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 467–473why, one step back467468The [current directory](#optionscwd) in which the command was run.469470[More info.](environment.md#current-directory)471472### result.durationMs473Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 474why, one step back474_Type:_ `number`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 475–481why, one step back475476Duration of the subprocess, in milliseconds.477478[More info.](debugging.md#duration)479480### result.failed481Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 482why, one step back482_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 483–485why, one step back483484Whether the subprocess failed to run.485Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 486–487why, one step back486When this is `true`, the result is an [`ExecaError`](#execaerror) instance with additional error-related properties.487Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 488–489why, one step back488[More info.](errors.md#subprocess-failure)489Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 490–491why, one step back490## ExecaError491## ExecaSyncErrorMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 492why, one step back492Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 493why, one step back493_Type:_ `Error`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 494–504why, one step back494495Result of a subprocess [failed execution](errors.md#subprocess-failure).496497This error is thrown as an exception. If the [`reject`](#optionsreject) option is false, it is returned instead.498499This has the same shape as [successful results](#result), with the following additional properties.500501[More info.](errors.md)502503### error.message504Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 505why, one step back505_Type:_ `string`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 506–512why, one step back506507Error message when the subprocess [failed](errors.md#subprocess-failure) to run.508509[More info.](errors.md#error-message)510511### error.shortMessage512Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 513why, one step back513_Type:_ `string`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 514–520why, one step back514515This is the same as [`error.message`](#errormessage) except it does not include the subprocess [output](output.md).516517[More info.](errors.md#error-message)518519### error.originalMessage520Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 521why, one step back521_Type:_ `string | undefined`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 522–528why, one step back522523Original error message. This is the same as [`error.message`](#errormessage) excluding the subprocess [output](output.md) and some additional information added by Execa.524525[More info.](errors.md#error-message)526527### error.cause528Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 529why, one step back529_Type:_ `unknown | undefined`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 530–538why, one step back530531Underlying error, if there is one. For example, this is set by [`subprocess.kill(error)`](#subprocesskillerror).532533This is usually an `Error` instance.534535[More info.](termination.md#error-message-and-stack-trace)536537### error.code538Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 539why, one step back539_Type:_ `string | undefined`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 540–544why, one step back540541Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.542543### error.timedOut544Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 545why, one step back545_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 546–550why, one step back546547Whether the subprocess timed out due to the [`timeout`](#optionstimeout) option.548549[More info.](termination.md#timeout)550Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 551why, one step back551### error.isCanceledMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 552why, one step back552Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 553why, one step back553_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 554–558why, one step back554555Whether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.556557[More info.](termination.md#canceling)558Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 559why, one step back559### error.isMaxBufferMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 560why, one step back560Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 561why, one step back561_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 562–566why, one step back562563Whether the subprocess failed because its output was larger than the [`maxBuffer`](#optionsmaxbuffer) option.564565[More info.](output.md#big-output)566Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 567why, one step back567### error.isTerminatedMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 568why, one step back568Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 569why, one step back569_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 570–576why, one step back570571Whether the subprocess was terminated by a [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) sent by either:572- The current process.573- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).574575[More info.](termination.md#signal-name-and-description)576Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 577why, one step back577### error.exitCodeMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 578why, one step back578Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 579why, one step back579_Type:_ `number | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 580–582why, one step back580581The numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.582Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 583why, one step back583This 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 584–586why, one step back584585[More info.](errors.md#exit-code)586Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 587why, one step back587### error.signalMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 588why, one step back588Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 589why, one step back589_Type:_ `string | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 590–598why, one step back590591The name of the [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) that terminated the subprocess, sent by either:592- The current process.593- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).594595If a signal terminated the subprocess, this property is defined and included in the [error message](#errormessage). Otherwise it is `undefined`.596597[More info.](termination.md#signal-name-and-description)598Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 599why, one step back599### error.signalDescriptionMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 600why, one step back600Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 601why, one step back601_Type:_ `string | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 602–610why, one step back602603A human-friendly description of the [signal](termination.md#signal-termination) that was used to terminate the subprocess.604605If 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.606607[More info.](termination.md#signal-name-and-description)608609## Options610Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 611why, one step back611_TypeScript:_ [`Options`](typescript.md) or [`SyncOptions`](typescript.md\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 612why, one step back612_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 613–619why, one step back613614This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).615616The 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).617618### options.preferLocal619Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 620–621why, one step back620_Type:_ `boolean`\621_Default:_ `true` with [`$`](#file-arguments-options), `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 622–628why, one step back622623Prefer locally installed binaries when looking for a binary to execute.624625[More info.](environment.md#local-binaries)626627### options.localDir628Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 629–630why, one step back629_Type:_ `string | URL`\630_Default:_ [`cwd`](#optionscwd) optionMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 631–637why, one step back631632Preferred path to find locally installed binaries, when using the [`preferLocal`](#optionspreferlocal) option.633634[More info.](environment.md#local-binaries)635636### options.node637Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 638–639why, one step back638_Type:_ `boolean`\639_Default:_ `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 640–642why, one step back640641If `true`, runs with Node.js. The first argument must be a Node.js file.642Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5
lines 643–644why, one step back643The 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.644Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 645–648why, one step back645[More info.](node.md)646647### options.nodeOptions648Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 649why, one step back649_Type:_ `string[]`\Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5
line 650why, one step back650_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 651–659why, one step back651652List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#optionsnodepath).653654Requires the [`node`](#optionsnode) option to be `true`.655656[More info.](node.md#nodejs-cli-flags)657658### options.nodePath659Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 660–661why, one step back660_Type:_ `string | URL`\661_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 662–670why, one step back662663Path to the Node.js executable.664665Requires the [`node`](#optionsnode) option to be `true`.666667[More info.](node.md#nodejs-version)668669### options.shell670Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 671–672why, one step back671_Type:_ `boolean | string | URL`\672_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 673–683why, one step back673674If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).675676Uses [`/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.677678We [recommend against](shell.md#avoiding-shells) using this option.679680[More info.](shell.md)681682### options.cwd683Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 684–685why, one step back684_Type:_ `string | URL`\685_Default:_ `process.cwd()`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 686–694why, one step back686687Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.688689This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.690691[More info.](environment.md#current-directory)692693### options.env694Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 695–696why, one step back695_Type:_ `object`\696_Default:_ [`process.env`](https://nodejs.org/api/process.html#processenv)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 697–705why, one step back697698[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).699700Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).701702[More info.](input.md#environment-variables)703704### options.extendEnv705Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 706–707why, one step back706_Type:_ `boolean`\707_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 708–715why, one step back708709If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).710If `false`, only the `env` option is used, not `process.env`.711712[More info.](input.md#environment-variables)713714### options.input715Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 716why, one step back716_Type:_ `string | Uint8Array | stream.Readable`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 717–725why, one step back717718Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).719720See also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options.721722[More info.](input.md#string-input)723724### options.inputFile725Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 726why, one step back726_Type:_ `string | URL`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 727–735why, one step back727728Use a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).729730See also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options.731732[More info.](input.md#file-input)733734### options.stdin735Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 736why, one step back736_TypeScript:_ [`StdinOption`](typescript.md) or [`StdinSyncOption`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 737–738why, one step back737_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)\738_Default:_ `'inherit'` with [`$`](#file-arguments-options), `'pipe'` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 739–747why, one step back739740How 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).741742This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.743744More info on [available values](input.md), [streaming](streams.md) and [transforms](transform.md).745746### options.stdout747Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 748why, one step back748_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 749–750why, one step back749_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)\750_Default:_ `pipe`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 751–759why, one step back751752How 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).753754This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.755756More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).757758### options.stderr759Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 760why, one step back760_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 761–762why, one step back761_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)\762_Default:_ `pipe`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 763–771why, one step back763764How 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).765766This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.767768More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).769770### options.stdio771Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 772why, one step back772_TypeScript:_ [`Options['stdio']`](typescript.md) or [`SyncOptions['stdio']`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 773–774why, one step back773_Type:_ `string | Array<string | number | stream.Readable | stream.Writable | ReadableStream | WritableStream | TransformStream | URL | {file: string} | Uint8Array | Iterable<string> | Iterable<Uint8Array> | Iterable<unknown> | AsyncIterable<string | Uint8Array | unknown> | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}>` (or a tuple of those types)\774_Default:_ `pipe`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 775–785why, one step back775776Like 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'}`.777778A single string can be used [as a shortcut](output.md#shortcut).779780The array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr).781782More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).783784### options.all785Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 786–787why, one step back786_Type:_ `boolean`\787_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 788–794why, one step back788789Add a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.790791[More info.](output.md#interleaved-output)792793### options.encoding794Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 795–796why, one step back795_Type:_ `'utf8' | 'utf16le' | 'buffer' | 'hex' | 'base64' | 'base64url' | 'latin1' | 'ascii'`\796_Default:_ `'utf8'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 797–809why, one step back797798If 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).799800If it outputs binary data instead, this should be either:801- `'buffer'`: returns the binary output as an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).802- [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64), [`'base64url'`](https://en.wikipedia.org/wiki/Base64#URL_applications), [`'latin1'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings) or [`'ascii'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings): encodes the binary output as a string.803804The output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).805806[More info.](binary.md)807808### options.lines809Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 810–811why, one step back810_Type:_ `boolean`\811_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 812–822why, one step back812813Set [`result.stdout`](#resultstdout), [`result.stderr`](#resultstdout), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) as arrays of strings, splitting the subprocess' output into lines.814815This cannot be used if the [`encoding`](#optionsencoding) option is [binary](binary.md#binary-output).816817By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).818819[More info.](lines.md#simple-splitting)820821### options.stripFinalNewline822Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 823–824why, one step back823_Type:_ `boolean`\824_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 825–835why, one step back825826Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.827828If the [`lines`](#optionslines) option is true, this applies to each output line instead.829830By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).831832[More info.](lines.md#newlines)833834### options.maxBuffer835Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 836–837why, one step back836_Type:_ `number`\837_Default:_ `100_000_000`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 838–846why, one step back838839Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).840841By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).842843[More info.](output.md#big-output)844845### options.buffer846Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 847–848why, one step back847_Type:_ `boolean`\848_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 849–857why, one step back849850When `buffer` is `false`, the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties are not set.851852By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).853854[More info.](output.md#low-memory)855856### options.ipc857Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 858–859why, one step back858_Type:_ `boolean`\859_Default:_ `true` if the [`node`](#optionsnode) option is enabled, `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 860–866why, one step back860861Enables exchanging messages with the subprocess using [`subprocess.send(message)`](#subprocesssendmessage) and [`subprocess.on('message', (message) => {})`](#subprocessonmessage-message--void).862863[More info.](ipc.md)864865### options.serialization866Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 867–868why, one step back867_Type:_ `'json' | 'advanced'`\868_Default:_ `'advanced'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 869–875why, one step back869870Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.871872[More info.](ipc.md#message-type)873874### options.verbose875Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 876–877why, one step back876_Type:_ `'none' | 'short' | 'full'`\877_Default:_ `'none'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 878–888why, one step back878879If `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.880881If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.882883By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).884885[More info.](debugging.md#verbose-mode)886887### options.reject888Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 889–890why, one step back889_Type:_ `boolean`\890_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 891why, one step back891Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 892why, one step back892Setting 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 893–897why, one step back893894[More info.](errors.md#preventing-exceptions)895896### options.timeout897Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 898–899why, one step back898_Type:_ `number`\899_Default:_ `0`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 900–902why, one step back900901If `timeout` is greater than `0`, the subprocess will be [terminated](#optionskillsignal) if it runs for longer than that amount of milliseconds.902Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 903why, one step back903On timeout, [`result.timedOut`](#errortimedout) becomes `true`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 904–908why, one step back904905[More info.](termination.md#timeout)906907### options.cancelSignal908Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 909why, one step back909_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 910–912why, one step back910911You can abort the subprocess using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).912Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 913why, one step back913When `AbortController.abort()` is called, [`result.isCanceled`](#erroriscanceled) becomes `true`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 914–918why, one step back914915[More info.](termination.md#canceling)916917### options.forceKillAfterDelay918Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 919–920why, one step back919_Type:_ `number | false`\920_Default:_ `5000`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 921–927why, one step back921922If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).923924[More info.](termination.md#forceful-termination)925926### options.killSignal927Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 928–929why, one step back928_Type:_ `string | number`\929_Default:_ `'SIGTERM'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 930–938why, one step back930931Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.932933This can be either a name (like [`'SIGTERM'`](termination.md#sigterm)) or a number (like `9`).934935[More info.](termination.md#default-signal)936937### options.detached938Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 939–940why, one step back939_Type:_ `boolean`\940_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 941–947why, one step back941942Run the subprocess independently from the current process.943944[More info.](environment.md#background-subprocess)945946### options.cleanup947Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 948–949why, one step back948_Type:_ `boolean`\949_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 950–956why, one step back950951Kill the subprocess when the current process exits.952953[More info.](termination.md#current-process-exit)954955### options.uid956Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 957–958why, one step back957_Type:_ `number`\958_Default:_ current user identifierMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 959–965why, one step back959960Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.961962[More info.](windows.md#uid-and-gid)963964### options.gid965Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 966–967why, one step back966_Type:_ `number`\967_Default:_ current group identifierMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 968–974why, one step back968969Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.970971[More info.](windows.md#uid-and-gid)972973### options.argv0974Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 975–976why, one step back975_Type:_ `string`\976_Default:_ file being executedMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 977–981why, one step back977978Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.979980### options.windowsHide981Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 982–983why, one step back982_Type:_ `boolean`\983_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 984–990why, one step back984985On Windows, do not create a new console window.986987[More info.](windows.md#console-window)988989### options.windowsVerbatimArguments990Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 991–992why, one step back991_Type:_ `boolean`\992_Default:_ `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 993–1007why, one step back993994If `false`, escapes the command arguments on Windows.995996[More info.](windows.md#cmdexe-escaping)997998## Transform options9991000A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.10011002A transform is either a [generator function](#transformoptionstransform) or a plain object with the following members.10031004[More info.](transform.md)10051006### transformOptions.transform1007Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 1008why, one step back1008_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1009–1015why, one step back10091010Map or [filter](transform.md#filtering) the [input](input.md) or [output](output.md) of the subprocess.10111012More info [here](transform.md#summary) and [there](transform.md#sharing-state).10131014### transformOptions.final1015Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 1016why, one step back1016_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1017–1023why, one step back10171018Create additional lines after the last one.10191020[More info.](transform.md#finalizing)10211022### transformOptions.binary1023Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1024–1025why, one step back1024_Type:_ `boolean`\1025_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1026–1032why, one step back10261027If `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.10281029[More info.](binary.md#transforms)10301031### transformOptions.preserveNewlines1032Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1033–1034why, one step back1033_Type:_ `boolean`\1034_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1035–1041why, one step back10351036If `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produces a single line.10371038[More info.](lines.md#transforms)10391040### transformOptions.objectMode1041Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1042–1043why, one step back1042_Type:_ `boolean`\1043_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1044–1052why, one step back10441045If `true`, allow [`transformOptions.transform`](#transformoptionstransform) and [`transformOptions.final`](#transformoptionsfinal) to return any type, not just `string` or `Uint8Array`.10461047[More info.](transform.md#object-mode)10481049<hr>10501051[**Previous**: 🔍 Differences with Bash and zx](bash.md)\1052[**Top**: Table of contents](../readme.md#documentation)