api.md
This file
Path
docs/api.md
1,371 lines · 55.1 KiB · Markdown
Last changed by
Fix `escapedCommand` and `verbose` quoting arguments when using the `shell` optionSindre Sorhusbefore adoptionb2c3a54
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
100% test coverage (#1018)ehmickybefore adoption9f65b86
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.100% test coverage (#1018)ehmickybefore adoption9f65b86
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)\100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 18–23why, one step back18_Returns_: [`ResultPromise`](#return-value)1920Executes a command using `file ...arguments`.2122More info on the [syntax](execution.md#array-syntax) and [escaping](escaping.md#array-syntax).23Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 24why, one step back24### $(file, arguments?, options?)100% test coverage (#1018)ehmickybefore adoption9f65b86
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)\100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 29–30why, one step back29_Returns_: [`ResultPromise`](#return-value)30Improve 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).100% test coverage (#1018)ehmickybefore adoption9f65b86
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.100% test coverage (#1018)ehmickybefore adoption9f65b86
line 34why, one step back34Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 35why, one step back35[More info.](scripts.md)100% test coverage (#1018)ehmickybefore adoption9f65b86
line 36why, one step back36Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 37why, one step back37### execaNode(scriptPath, arguments?, options?)100% test coverage (#1018)ehmickybefore adoption9f65b86
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)100% test coverage (#1018)ehmickybefore adoption9f65b86
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`.100% test coverage (#1018)ehmickybefore adoption9f65b86
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)50100% test coverage (#1018)ehmickybefore adoption9f65b86
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?)100% test coverage (#1018)ehmickybefore adoption9f65b86
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)\100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 58–59why, one step back58_Returns_: [`SyncResult`](#return-value)59Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 60why, one step back60Same as [`execa()`](#execafile-arguments-options) and [`$`](#file-arguments-options) but synchronous.100% test coverage (#1018)ehmickybefore adoption9f65b86
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.100% test coverage (#1018)ehmickybefore adoption9f65b86
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.65100% test coverage (#1018)ehmickybefore adoption9f65b86
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\`100% test coverage (#1018)ehmickybefore adoption9f65b86
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)100% test coverage (#1018)ehmickybefore adoption9f65b86
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`.100% test coverage (#1018)ehmickybefore adoption9f65b86
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).100% test coverage (#1018)ehmickybefore adoption9f65b86
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\`100% test coverage (#1018)ehmickybefore adoption9f65b86
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)100% test coverage (#1018)ehmickybefore adoption9f65b86
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).100% test coverage (#1018)ehmickybefore adoption9f65b86
line 94why, one step back94Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 95why, one step back95[More info.](execution.md#template-string-syntax)100% test coverage (#1018)ehmickybefore adoption9f65b86
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)100% test coverage (#1018)ehmickybefore adoption9f65b86
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)100% test coverage (#1018)ehmickybefore adoption9f65b86
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.100% test coverage (#1018)ehmickybefore adoption9f65b86
line 108why, one step back108Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 109why, one step back109[More info.](execution.md#globalshared-options)100% test coverage (#1018)ehmickybefore adoption9f65b86
line 110why, one step back110Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3
line 111why, one step back111### parseCommandString(command)100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 112–113why, one step back112113`command`: `string`\Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3
line 114why, one step back114_Returns_: `string[]`100% test coverage (#1018)ehmickybefore adoption9f65b86
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']`.100% test coverage (#1018)ehmickybefore adoption9f65b86
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)210100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 211–213why, one step back211## Return value212213_TypeScript:_ [`ResultPromise`](typescript.md)\Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 214why, one step back214_Type:_ `Subprocess`100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 215–225why, one step back215216The return value of all [asynchronous methods](#methods) is both:217- the [subprocess](#subprocess).218- a `Promise` either resolving with its successful [`result`](#result), or rejecting with its [`error`](#execaerror).219220[More info.](execution.md#subprocess)221222## Subprocess223224_TypeScript:_ [`Subprocess`](typescript.md)225Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 226why, one step back226Promise with the following Execa-specific methods and properties.100% test coverage (#1018)ehmickybefore adoption9f65b86
line 227why, one step back227Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
lines 228–229why, one step back228The underlying Node.js [`ChildProcess`](https://nodejs.org/api/child_process.html#class-childprocess) instance is available as [`subprocess.nodeChildProcess`](#subprocessnodechildprocess). This is an escape hatch for Node.js-specific APIs that Execa does not document, such as `.on()`, `.send()`, `.disconnect()`, `.ref()` and `.unref()`.229100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 230–250why, one step back230### subprocess\[Symbol.asyncIterator\]()231232_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)233234Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.235236[More info.](lines.md#progressive-splitting)237238### subprocess.iterable(readableOptions?)239240`readableOptions`: [`ReadableOptions`](#readableoptions)\241_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)242243Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.244245[More info.](lines.md#progressive-splitting)246247### subprocess.pipe(file, arguments?, options?)248249`file`: `string | URL`\250`arguments`: `string[]`\Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 251why, one step back251`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 252–255why, one step back252_Returns_: [`Promise<Result>`](#result)253254[Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the subprocess' [`stdout`](#subprocessstdout) to a second Execa subprocess' [`stdin`](#subprocessstdin). This resolves with that second subprocess' [result](#result). If either subprocess is rejected, this is rejected with that subprocess' [error](#execaerror) instead.255Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 256why, one step back256This 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.100% test coverage (#1018)ehmickybefore adoption9f65b86
line 257why, one step back257Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 258–259why, one step back258Like 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.259100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 260–265why, one step back260[More info.](pipe.md#array-syntax)261262### subprocess.pipe\`command\`263### subprocess.pipe(options)\`command\`264265`command`: `string`\Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813
line 266why, one step back266`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 267–268why, one step back267_Returns_: [`Promise<Result>`](#result)268Fix broken Markdown links (#1119)ehmickybefore adoption8572eb1
line 269why, one step back269Like [`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).100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 270–338why, one step back270271[More info.](pipe.md#template-string-syntax)272273### subprocess.pipe(secondSubprocess, pipeOptions?)274275`secondSubprocess`: [`ResultPromise`](#return-value)\276`pipeOptions`: [`PipeOptions`](#pipeoptions)\277_Returns_: [`Promise<Result>`](#result)278279Like [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using the [return value](#return-value) of another [`execa()`](#execafile-arguments-options) call instead.280281[More info.](pipe.md#advanced-syntax)282283#### pipeOptions284285_Type:_ `object`286287#### pipeOptions.from288289_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\290_Default:_ `"stdout"`291292Which stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.293294`"all"` pipes both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.295296[More info.](pipe.md#source-file-descriptor)297298#### pipeOptions.to299300_Type:_ `"stdin" | "fd3" | "fd4" | ...`\301_Default:_ `"stdin"`302303Which [stream](#subprocessstdin) to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.304305[More info.](pipe.md#destination-file-descriptor)306307#### pipeOptions.unpipeSignal308309_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)310311Unpipe the subprocess when the signal aborts.312313[More info.](pipe.md#unpipe)314315### subprocess.kill(signal, error?)316### subprocess.kill(error?)317318`signal`: `string | number`\319`error`: `Error`\320_Returns_: `boolean`321322Sends a [signal](https://nodejs.org/api/os.html#signal-constants) to the subprocess. The default signal is the [`killSignal`](#optionskillsignal) option. `killSignal` defaults to `SIGTERM`, which [terminates](#erroristerminated) the subprocess.323324This returns `false` when the signal could not be sent, for example when the subprocess has already exited.325326When an error is passed as argument, it is set to the subprocess' [`error.cause`](#errorcause). The subprocess is then terminated with the default signal. This does not emit the [`error` event](https://nodejs.org/api/child_process.html#event-error).327328[More info.](termination.md)329330### subprocess.pid331332_Type:_ `number | undefined`333334Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).335336This is `undefined` if the subprocess failed to spawn.337338[More info.](termination.md#inter-process-termination)Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
lines 339–346why, one step back339340### subprocess.nodeChildProcess341342_Type:_ [`ChildProcess`](https://nodejs.org/api/child_process.html#class-childprocess)343344Underlying Node.js child process instance.345346This is intended as an escape hatch for Node.js-specific APIs that Execa does not document.100% test coverage (#1018)ehmickybefore adoption9f65b86
line 347why, one step back347Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 348why, one step back348### subprocess.sendMessage(message, sendMessageOptions)100% test coverage (#1018)ehmickybefore adoption9f65b86
line 349why, one step back349Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 350why, one step back350`message`: [`Message`](ipc.md#message-type)\Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 351why, one step back351`sendMessageOptions`: [`SendMessageOptions`](#sendmessageoptions)\Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 352why, one step back352_Returns_: `Promise<void>`100% test coverage (#1018)ehmickybefore adoption9f65b86
line 353why, one step back353Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 354why, one step back354Send a `message` to the subprocess.100% test coverage (#1018)ehmickybefore adoption9f65b86
line 355why, one step back355Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 356why, one step back356This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 357–359why, one step back357358[More info.](ipc.md#exchanging-messages)359Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
line 360why, one step back360### subprocess.getOneMessage(getOneMessageOptions?)100% test coverage (#1018)ehmickybefore adoption9f65b86
line 361why, one step back361Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 362why, one step back362`getOneMessageOptions`: [`GetOneMessageOptions`](#getonemessageoptions)\Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 363why, one step back363_Returns_: [`Promise<Message>`](ipc.md#message-type)100% test coverage (#1018)ehmickybefore adoption9f65b86
line 364why, one step back364Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 365why, one step back365Receive a single `message` from the subprocess.100% test coverage (#1018)ehmickybefore adoption9f65b86
line 366why, one step back366Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 367why, one step back367This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 368–370why, one step back368369[More info.](ipc.md#exchanging-messages)370Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
line 371why, one step back371### subprocess.getEachMessage(getEachMessageOptions?)Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 372why, one step back372Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
line 373why, one step back373`getEachMessageOptions`: [`GetEachMessageOptions`](#geteachmessageoptions)\Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 374–381why, one step back374_Returns_: [`AsyncIterable<Message>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)375376Iterate over each `message` from the subprocess.377378This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.379380[More info.](ipc.md#listening-to-messages)381100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 382–397why, one step back382### subprocess.stdin383384_Type:_ [`Writable | null`](https://nodejs.org/api/stream.html#class-streamwritable)385386The subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.387388This is `null` if the [`stdin`](#optionsstdin) option is set to [`'inherit'`](input.md#terminal-input), [`'ignore'`](input.md#ignore-input), [`Readable`](streams.md#input) or [`integer`](input.md#terminal-input).389390[More info.](streams.md#manual-streaming)391392### subprocess.stdout393394_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)395396The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.397Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
line 398why, one step back398This 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).100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 399–407why, one step back399400[More info.](streams.md#manual-streaming)401402### subprocess.stderr403404_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)405406The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.407Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
line 408why, one step back408This is `null` if the [`stderr`](#optionsstderr) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output).100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 409–419why, one step back409410[More info.](streams.md#manual-streaming)411412### subprocess.all413414_Type:_ [`Readable | undefined`](https://nodejs.org/api/stream.html#class-streamreadable)415416Stream combining/interleaving [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).417418This requires the [`all`](#optionsall) option to be `true`.419Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f
line 420why, one step back420This is `undefined` if both [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output).100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 421–429why, one step back421422More info on [interleaving](output.md#interleaved-output) and [streaming](streams.md#manual-streaming).423424### subprocess.stdio425426_Type:_ [`[Writable | null, Readable | null, Readable | null, ...Array<Writable | Readable | null>]`](https://nodejs.org/api/stream.html#class-streamreadable)427428The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.429Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
line 430why, one step back430Each 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).100% test coverage (#1018)ehmickybefore adoption9f65b86
line 431why, one step back431Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
lines 432–433why, one step back432With the [`ipc`](#optionsipc) option, the last item is the subprocess' IPC channel, which is always `null`.433100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 434–512why, one step back434[More info.](streams.md#manual-streaming)435436### subprocess.readable(readableOptions?)437438`readableOptions`: [`ReadableOptions`](#readableoptions)\439_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream440441Converts the subprocess to a readable stream.442443[More info.](streams.md#converting-a-subprocess-to-a-stream)444445#### readableOptions446447_Type:_ `object`448449#### readableOptions.from450451_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\452_Default:_ `"stdout"`453454Which stream to read from the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.455456`"all"` reads both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.457458[More info.](streams.md#different-file-descriptor)459460#### readableOptions.binary461462_Type:_ `boolean`\463_Default:_ `false` with [`subprocess.iterable()`](#subprocessiterablereadableoptions), `true` with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)464465If `false`, iterates over lines. Each line is a string.466467If `true`, iterates over arbitrary chunks of data. Each line is an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) (with [`subprocess.iterable()`](#subprocessiterablereadableoptions)) or a [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) (with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)).468469This is always `true` when the [`encoding`](#optionsencoding) option is binary.470471More info for [iterables](binary.md#iterable) and [streams](binary.md#streams).472473#### readableOptions.preserveNewlines474475_Type:_ `boolean`\476_Default:_ `false` with [`subprocess.iterable()`](#subprocessiterablereadableoptions), `true` with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)477478If both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.479480[More info.](lines.md#iterable)481482### subprocess.writable(writableOptions?)483484`writableOptions`: [`WritableOptions`](#writableoptions)\485_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream486487Converts the subprocess to a writable stream.488489[More info.](streams.md#converting-a-subprocess-to-a-stream)490491#### writableOptions492493_Type:_ `object`494495#### writableOptions.to496497_Type:_ `"stdin" | "fd3" | "fd4" | ...`\498_Default:_ `"stdin"`499500Which [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.501502[More info.](streams.md#different-file-descriptor)503504### subprocess.duplex(duplexOptions?)505506`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\507_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream508509Converts the subprocess to a duplex stream.510511[More info.](streams.md#converting-a-subprocess-to-a-stream)512Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 513–539why, one step back513### subprocess.readableStream(readableOptions?)514515`readableOptions`: [`ReadableOptions`](#readableoptions)\516_Returns_: [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) web stream517518Converts the subprocess to a readable web stream.519520[More info.](streams.md#converting-a-subprocess-to-a-web-stream)521522### subprocess.writableStream(writableOptions?)523524`writableOptions`: [`WritableOptions`](#writableoptions)\525_Returns_: [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream) web stream526527Converts the subprocess to a writable web stream.528529[More info.](streams.md#converting-a-subprocess-to-a-web-stream)530531### subprocess.transformStream(duplexOptions?)532533`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\534_Returns_: [`{readable: ReadableStream, writable: WritableStream}`](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream)535536Converts the subprocess to a [`{readable, writable}`](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream) pair of web streams.537538[More info.](streams.md#converting-a-subprocess-to-a-web-stream)539100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 540–541why, one step back540## Result541Improve documentation of signal handling (#1105)ehmickybefore adoption01a4b42
line 542why, one step back542_TypeScript:_ [`Result`](typescript.md) or [`SyncResult`](typescript.md)\100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 543–580why, one step back543_Type:_ `object`544545[Result](execution.md#result) of a subprocess successful execution.546547When the subprocess [fails](errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.548549### result.stdout550551_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`552553The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).554555This is `undefined` if the [`stdout`](#optionsstdout) option is set to only [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.556557This is an array if the [`lines`](#optionslines) option is `true`, or if the `stdout` option is a [transform in object mode](transform.md#object-mode).558559[More info.](output.md#stdout-and-stderr)560561### result.stderr562563_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`564565The output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).566567This is `undefined` if the [`stderr`](#optionsstderr) option is set to only [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.568569This is an array if the [`lines`](#optionslines) option is `true`, or if the `stderr` option is a [transform in object mode](transform.md#object-mode).570571[More info.](output.md#stdout-and-stderr)572573### result.all574575_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`576577The output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) interleaved.578579This requires the [`all`](#optionsall) option to be `true`.580Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f
line 581why, one step back581This is `undefined` if both [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to only [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false` for both.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 582–594why, one step back582583This is an array if the [`lines`](#optionslines) option is `true`, or if either the `stdout` or `stderr` option is a [transform in object mode](transform.md#object-mode).584585[More info.](output.md#interleaved-output)586587### result.stdio588589_Type:_ `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`590591The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).592593Items are `undefined` when their corresponding [`stdio`](#optionsstdio) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.594Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
lines 595–596why, one step back595With the [`ipc`](#optionsipc) option, the last item is the subprocess' IPC channel, which is always `undefined`.596100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 597–600why, one step back597Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).598599[More info.](output.md#additional-file-descriptors)600Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 601why, one step back601### result.ipcOutputAdd `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de
line 602why, one step back602Fix type of `result.ipc` (#1071)ehmickybefore adoption69152ec
line 603why, one step back603_Type_: [`Message[]`](ipc.md#message-type)Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de
line 604why, one step back604Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 605why, one step back605All the messages [sent by the subprocess](#sendmessagemessage-sendmessageoptions) to the current process.Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de
lines 606–610why, one step back606607This is empty unless the [`ipc`](#optionsipc) option is `true`. Also, this is empty if the [`buffer`](#optionsbuffer) option is `false`.608609[More info.](ipc.md#retrieve-all-messages)610100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 611–634why, one step back611### result.pipedFrom612613_Type:_ [`Array<Result | ExecaError>`](#result)614615[Results](#result) of the other subprocesses that were piped into this subprocess.616617This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.618619[More info.](pipe.md#result)620621### result.command622623_Type:_ `string`624625The file and [arguments](input.md#command-arguments) that were run.626627[More info.](debugging.md#command)628629### result.escapedCommand630631_Type:_ `string`632633Same as [`command`](#resultcommand) but escaped.634Fix `escapedCommand` and `verbose` quoting arguments when using the `shell` optionSindre Sorhusbefore adoptionb2c3a54
lines 635–636why, one step back635With the [`shell`](#optionsshell) option, the command is not quoted, since the shell interprets it.636100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 637–733why, one step back637[More info.](debugging.md#command)638639### result.cwd640641_Type:_ `string`642643The [current directory](#optionscwd) in which the command was run.644645[More info.](environment.md#current-directory)646647### result.durationMs648649_Type:_ `number`650651Duration of the subprocess, in milliseconds.652653[More info.](debugging.md#duration)654655### result.failed656657_Type:_ `boolean`658659Whether the subprocess failed to run.660661When this is `true`, the result is an [`ExecaError`](#execaerror) instance with additional error-related properties.662663[More info.](errors.md#subprocess-failure)664665## ExecaError666## ExecaSyncError667668_Type:_ `Error`669670Result of a subprocess [failed execution](errors.md#subprocess-failure).671672This error is thrown as an exception. If the [`reject`](#optionsreject) option is false, it is returned instead.673674This has the same shape as [successful results](#result), with the following additional properties.675676[More info.](errors.md)677678### error.message679680_Type:_ `string`681682Error message when the subprocess [failed](errors.md#subprocess-failure) to run.683684[More info.](errors.md#error-message)685686### error.shortMessage687688_Type:_ `string`689690This is the same as [`error.message`](#errormessage) except it does not include the subprocess [output](output.md).691692[More info.](errors.md#error-message)693694### error.originalMessage695696_Type:_ `string | undefined`697698Original error message. This is the same as [`error.message`](#errormessage) excluding the subprocess [output](output.md) and some additional information added by Execa.699700[More info.](errors.md#error-message)701702### error.cause703704_Type:_ `unknown | undefined`705706Underlying error, if there is one. For example, this is set by [`subprocess.kill(error)`](#subprocesskillerror).707708This is usually an `Error` instance.709710[More info.](termination.md#error-message-and-stack-trace)711712### error.code713714_Type:_ `string | undefined`715716Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.717718### error.timedOut719720_Type:_ `boolean`721722Whether the subprocess timed out due to the [`timeout`](#optionstimeout) option.723724[More info.](termination.md#timeout)725726### error.isCanceled727728_Type:_ `boolean`729730Whether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.731732[More info.](termination.md#canceling)733Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
lines 734–741why, one step back734### error.isGracefullyCanceled735736_Type:_ `boolean`737738Whether the subprocess was canceled using both the [`cancelSignal`](#optionscancelsignal) and the [`gracefulCancel`](#optionsgracefulcancel) options.739740[More info.](termination.md#graceful-termination)741100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 742–759why, one step back742### error.isMaxBuffer743744_Type:_ `boolean`745746Whether the subprocess failed because its output was larger than the [`maxBuffer`](#optionsmaxbuffer) option.747748[More info.](output.md#big-output)749750### error.isTerminated751752_Type:_ `boolean`753754Whether the subprocess was terminated by a [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) sent by either:755- The current process.756- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).757758[More info.](termination.md#signal-name-and-description)759Add `error.isForcefullyTerminated` (#1111)ehmickybefore adoptione69985d
lines 760–767why, one step back760### error.isForcefullyTerminated761762_Type:_ `boolean`763764Whether the subprocess was terminated by the [`SIGKILL`](termination.md#sigkill) signal sent by the [`forceKillAfterDelay`](#optionsforcekillafterdelay) option.765766[More info.](termination.md#forceful-termination)767100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 768–801why, one step back768### error.exitCode769770_Type:_ `number | undefined`771772The numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.773774This is `undefined` when the subprocess could not be spawned or was terminated by a [signal](#errorsignal).775776[More info.](errors.md#exit-code)777778### error.signal779780_Type:_ `string | undefined`781782The name of the [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) that terminated the subprocess, sent by either:783- The current process.784- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).785786If a signal terminated the subprocess, this property is defined and included in the [error message](#errormessage). Otherwise it is `undefined`.787788[More info.](termination.md#signal-name-and-description)789790### error.signalDescription791792_Type:_ `string | undefined`793794A human-friendly description of the [signal](termination.md#signal-termination) that was used to terminate the subprocess.795796If 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.797798[More info.](termination.md#signal-name-and-description)799800## Options801Fix a typo (#1153)Reuben Thomasbefore adoption3fc8049
line 802why, one step back802_TypeScript:_ [`Options`](typescript.md) or [`SyncOptions`](typescript.md)\100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 803–886why, one step back803_Type:_ `object`804805This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).806807The 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).808809### options.preferLocal810811_Type:_ `boolean`\812_Default:_ `true` with [`$`](#file-arguments-options), `false` otherwise813814Prefer locally installed binaries when looking for a binary to execute.815816[More info.](environment.md#local-binaries)817818### options.localDir819820_Type:_ `string | URL`\821_Default:_ [`cwd`](#optionscwd) option822823Preferred path to find locally installed binaries, when using the [`preferLocal`](#optionspreferlocal) option.824825[More info.](environment.md#local-binaries)826827### options.node828829_Type:_ `boolean`\830_Default:_ `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwise831832If `true`, runs with Node.js. The first argument must be a Node.js file.833834The 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.835836[More info.](node.md)837838### options.nodeOptions839840_Type:_ `string[]`\841_Default:_ [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI flags)842843List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#optionsnodepath).844845Requires the [`node`](#optionsnode) option to be `true`.846847[More info.](node.md#nodejs-cli-flags)848849### options.nodePath850851_Type:_ `string | URL`\852_Default:_ [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)853854Path to the Node.js executable.855856Requires the [`node`](#optionsnode) option to be `true`.857858[More info.](node.md#nodejs-version)859860### options.shell861862_Type:_ `boolean | string | URL`\863_Default:_ `false`864865If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).866867Uses [`/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.868869We [recommend against](shell.md#avoiding-shells) using this option.870871[More info.](shell.md)872873### options.cwd874875_Type:_ `string | URL`\876_Default:_ `process.cwd()`877878Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.879880This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.881882[More info.](environment.md#current-directory)883884### options.env885886_Type:_ `object`\Fix `extendEnv: false` inheriting `process.env` when `env` is not setSindre Sorhusbefore adoption67acf60
line 887why, one step back887_Default:_ `{}`100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 888–900why, one step back888889[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).890891Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).892893[More info.](input.md#environment-variables)894895### options.extendEnv896897_Type:_ `boolean`\898_Default:_ `true`899900If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).TweaksSindre Sorhusbefore adoption698a1b8
line 901why, one step back901If `false`, only the `env` option is used, not `process.env`. However, when `env` has no `PATH`, the [`preferLocal`](#optionspreferlocal) and [`node`](#optionsnode) options still add their directories to `process.env.PATH`.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 902–963why, one step back902903[More info.](input.md#environment-variables)904905### options.input906907_Type:_ `string | Uint8Array | stream.Readable`908909Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).910911See also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options.912913[More info.](input.md#string-input)914915### options.inputFile916917_Type:_ `string | URL`918919Use a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).920921See also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options.922923[More info.](input.md#file-input)924925### options.stdin926927_TypeScript:_ [`StdinOption`](typescript.md) or [`StdinSyncOption`](typescript.md)\928_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)\929_Default:_ `'inherit'` with [`$`](#file-arguments-options), `'pipe'` otherwise930931How 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).932933This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.934935More info on [available values](input.md), [streaming](streams.md) and [transforms](transform.md).936937### options.stdout938939_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\940_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)\941_Default:_ `pipe`942943How 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).944945This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.946947More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).948949### options.stderr950951_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\952_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)\953_Default:_ `pipe`954955How 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).956957This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.958959More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).960961### options.stdio962963_TypeScript:_ [`Options['stdio']`](typescript.md) or [`SyncOptions['stdio']`](typescript.md)\Generalize `{value, input}` to any direction-ambiguous stdio value (#1249)Sindre Sorhusbefore adoption9fbf5ba
line 964why, one step back964_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)\100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 965–970why, one step back965_Default:_ `pipe`966967Like 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'}`.968969A single string can be used [as a shortcut](output.md#shortcut).970Generalize `{value, input}` to any direction-ambiguous stdio value (#1249)Sindre Sorhusbefore adoption9fbf5ba
line 971why, one step back971The 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}`.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 972–992why, one step back972973More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).974975### options.all976977_Type:_ `boolean`\978_Default:_ `false`979980Add a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.981982[More info.](output.md#interleaved-output)983984### options.encoding985986_Type:_ `'utf8' | 'utf16le' | 'buffer' | 'hex' | 'base64' | 'base64url' | 'latin1' | 'ascii'`\987_Default:_ `'utf8'`988989If 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).990991If it outputs binary data instead, this should be either:992- `'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 993why, one step back993- [`'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.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 994–996why, one step back994995The output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).996Fix the `encoding` option and line splitting in transformsSindre Sorhusbefore adoption6adb3c3
lines 997–998why, one step back997String input passed with the [`input`](#optionsinput) or [`stdin`](#optionsstdin) option is always encoded with UTF-8, whatever this option is. With a text encoding, [`stdin` transforms](transform.md) also decode their input with UTF-8.998100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 999–1035why, one step back999[More info.](binary.md)10001001### options.lines10021003_Type:_ `boolean`\1004_Default:_ `false`10051006Set [`result.stdout`](#resultstdout), [`result.stderr`](#resultstdout), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) as arrays of strings, splitting the subprocess' output into lines.10071008This cannot be used if the [`encoding`](#optionsencoding) option is [binary](binary.md#binary-output).10091010By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10111012[More info.](lines.md#simple-splitting)10131014### options.stripFinalNewline10151016_Type:_ `boolean`\1017_Default:_ `true`10181019Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.10201021If the [`lines`](#optionslines) option is true, this applies to each output line instead.10221023By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10241025[More info.](lines.md#newlines)10261027### options.maxBuffer10281029_Type:_ `number`\1030_Default:_ `100_000_000`10311032Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).10331034By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).1035Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
line 1036why, one step back1036With [synchronous methods](execution.md#synchronous-execution), this cannot be enforced per file descriptor while the subprocess runs, since `spawnSync()` only accepts a single value, which limits the total output of all file descriptors. The `maxBuffer.stdout` value is used for it. The other file descriptors' own values are enforced from the output, once the subprocess ended, and cannot be higher than `maxBuffer.stdout`. Also, with synchronous methods, this is measured in bytes instead of [characters or lines](output.md#big-output), for the same reason.Fix `maxBuffer` being ignored or wrongly appliedSindre Sorhusbefore adoption9547e51
line 1037why, one step back1037Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
lines 1038–1039why, one step back1038When reached, [`error.isMaxBuffer`](#errorismaxbuffer) becomes `true`.1039100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1040–1055why, one step back1040[More info.](output.md#big-output)10411042### options.buffer10431044_Type:_ `boolean`\1045_Default:_ `true`10461047When `buffer` is `false`, the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties are not set.10481049By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10501051[More info.](output.md#low-memory)10521053### options.ipc10541055_Type:_ `boolean`\Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 1056why, one step back1056_Default:_ `true` if the [`node`](#optionsnode), [`ipcInput`](#optionsipcinput) or [`gracefulCancel`](#optionsgracefulcancel) option is set, `false` otherwise100% test coverage (#1018)ehmickybefore adoption9f65b86
line 1057why, one step back1057Fix broken Markdown links (#1119)ehmickybefore adoption8572eb1
line 1058why, one step back1058Enables exchanging messages with the subprocess using [`subprocess.sendMessage(message)`](#subprocesssendmessagemessage-sendmessageoptions), [`subprocess.getOneMessage()`](#subprocessgetonemessagegetonemessageoptions) and [`subprocess.getEachMessage()`](#subprocessgeteachmessagegeteachmessageoptions).100% test coverage (#1018)ehmickybefore adoption9f65b86
line 1059why, one step back1059Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 1060–1061why, one step back1060The subprocess must be a Node.js file.1061100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1062–1071why, one step back1062[More info.](ipc.md)10631064### options.serialization10651066_Type:_ `'json' | 'advanced'`\1067_Default:_ `'advanced'`10681069Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.10701071[More info.](ipc.md#message-type)Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 1072–1081why, one step back10721073### options.ipcInput10741075_Type_: [`Message`](ipc.md#message-type)10761077Sends an IPC message when the subprocess starts.10781079The subprocess must be a [Node.js file](#optionsnode). The value's [type](ipc.md#message-type) depends on the [`serialization`](#optionsserialization) option.10801081More info [here](ipc.md#send-an-initial-message) and [there](input.md#any-input-type).100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1082–1084why, one step back10821083### options.verbose1084Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 1085why, one step back1085_Type:_ `'none' | 'short' | 'full' | Function`\100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1086–1089why, one step back1086_Default:_ `'none'`10871088If `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.1089Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 1090why, one step back1090If `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.100% test coverage (#1018)ehmickybefore adoption9f65b86
line 1091why, one step back1091Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 1092–1093why, one step back1092A [function](#verbose-function) can be passed to customize logging. Please see [this page](debugging.md#custom-logging) for more information.1093100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1094–1111why, one step back1094By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).10951096[More info.](debugging.md#verbose-mode)10971098### options.reject10991100_Type:_ `boolean`\1101_Default:_ `true`11021103Setting this to `false` resolves the [result's promise](#return-value) with the [error](#execaerror) instead of rejecting it.11041105[More info.](errors.md#preventing-exceptions)11061107### options.timeout11081109_Type:_ `number`\1110_Default:_ `0`1111Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
line 1112why, one step back1112If `timeout` is greater than `0`, the subprocess will be [terminated](#optionskillsignal) if it runs for longer than that amount of milliseconds. It must be a non-negative integer, up to `2147483647` (about 24.8 days).100% test coverage (#1018)ehmickybefore adoption9f65b86
line 1113why, one step back1113Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 1114why, one step back1114On timeout, [`error.timedOut`](#errortimedout) becomes `true`.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1115–1121why, one step back11151116[More info.](termination.md#timeout)11171118### options.cancelSignal11191120_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)1121Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 1122why, one step back1122When the `cancelSignal` is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), terminate the subprocess using a `SIGTERM` signal.100% test coverage (#1018)ehmickybefore adoption9f65b86
line 1123why, one step back1123Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 1124why, one step back1124When aborted, [`error.isCanceled`](#erroriscanceled) becomes `true`.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1125–1126why, one step back11251126[More info.](termination.md#canceling)Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
lines 1127–1139why, one step back11271128### options.gracefulCancel11291130_Type:_ `boolean`\1131_Default:_: `false`11321133When 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.11341135The subprocess must be a [Node.js file](#optionsnode).11361137When aborted, [`error.isGracefullyCanceled`](#errorisgracefullycanceled) becomes `true`.11381139[More info.](termination.md#graceful-termination)100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1140–1142why, one step back11401141### options.forceKillAfterDelay1142Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
line 1143why, one step back1143_Type:_ `number | boolean`\100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1144–1145why, one step back1144_Default:_ `5000`1145Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
line 1146why, one step back1146If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL). The delay must be a non-negative integer, up to `2147483647` milliseconds (about 24.8 days). When `true`, the default `5000` is used. When `false`, the subprocess is not forcefully exited.Add `error.isForcefullyTerminated` (#1111)ehmickybefore adoptione69985d
lines 1147–1148why, one step back11471148When this happens, [`error.isForcefullyTerminated`](#errorisforcefullyterminated) becomes `true`.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1149–1180why, one step back11491150[More info.](termination.md#forceful-termination)11511152### options.killSignal11531154_Type:_ `string | number`\1155_Default:_ `'SIGTERM'`11561157Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.11581159This can be either a name (like [`'SIGTERM'`](termination.md#sigterm)) or a number (like `9`).11601161[More info.](termination.md#default-signal)11621163### options.detached11641165_Type:_ `boolean`\1166_Default:_ `false`11671168Run the subprocess independently from the current process.11691170[More info.](environment.md#background-subprocess)11711172### options.cleanup11731174_Type:_ `boolean`\1175_Default:_ `true`11761177Kill the subprocess when the current process exits.11781179[More info.](termination.md#current-process-exit)1180Add `killDescendants` option to also terminate descendant processes (#1256)Sindre Sorhusbefore adoption84fa0ec
lines 1181–1191why, one step back1181### options.killDescendants11821183_Type:_ `boolean`\1184_Default:_ `false`11851186When the subprocess is terminated by Execa, also terminate all of its descendant processes, instead of only the subprocess itself.11871188This is useful when the subprocess spawns its own processes, such as when using the [`shell`](#optionsshell) option.11891190On Unix, this spawns the subprocess in its own [process group](https://en.wikipedia.org/wiki/Process_group). On Windows, this uses [`taskkill`](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill).1191TweaksSindre Sorhusbefore adoption698a1b8
line 1192why, one step back1192This is best-effort: descendant processes that create their own process group or session are not terminated. Also, on Windows, descendants are not terminated once the subprocess exited, since its PID might then belong to an unrelated process.Add `killDescendants` option to also terminate descendant processes (#1256)Sindre Sorhusbefore adoption84fa0ec
lines 1193–1195why, one step back11931194[More info.](termination.md#killing-descendant-processes)1195100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1196–1236why, one step back1196### options.uid11971198_Type:_ `number`\1199_Default:_ current user identifier12001201Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.12021203[More info.](windows.md#uid-and-gid)12041205### options.gid12061207_Type:_ `number`\1208_Default:_ current group identifier12091210Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.12111212[More info.](windows.md#uid-and-gid)12131214### options.argv012151216_Type:_ `string`\1217_Default:_ file being executed12181219Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.12201221### options.windowsHide12221223_Type:_ `boolean`\1224_Default:_ `true`12251226On Windows, do not create a new console window.12271228[More info.](windows.md#console-window)12291230### options.windowsVerbatimArguments12311232_Type:_ `boolean`\1233_Default:_ `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwise12341235If `false`, escapes the command arguments on Windows.1236Improve documentation for `windowsVerbatimArguments` (#1149)ehmickybefore adoptionc4cb62a
line 1237why, one step back1237[More info.](windows.md#escaping)Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 1238–1272why, one step back12381239## Verbose function12401241_Type_: `(string, VerboseObject) => string | undefined`12421243Function passed to the [`verbose`](#optionsverbose) option to customize logging.12441245[More info.](debugging.md#custom-logging)12461247### Verbose object12481249_Type_: `VerboseObject` or `SyncVerboseObject`12501251Subprocess event object, for logging purpose, using the [`verbose`](#optionsverbose) option.12521253#### verboseObject.type12541255_Type_: `string`12561257Event type. This can be:1258- `'command'`: subprocess start1259- `'output'`: `stdout`/`stderr` [output](output.md#stdout-and-stderr)1260- `'ipc'`: IPC [output](ipc.md#retrieve-all-messages)1261- `'error'`: subprocess [failure](errors.md#subprocess-failure)1262- `'duration'`: subprocess success or failure12631264#### verboseObject.message12651266_Type_: `string`12671268Depending on [`verboseObject.type`](#verboseobjecttype), this is:1269- `'command'`: the [`result.escapedCommand`](#resultescapedcommand)1270- `'output'`: one line from [`result.stdout`](#resultstdout) or [`result.stderr`](#resultstderr)1271- `'ipc'`: one IPC message from [`result.ipcOutput`](#resultipcoutput)1272- `'error'`: the [`error.shortMessage`](#errorshortmessage)Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
line 1273why, one step back1273- `'duration'`: the [`result.durationMs`](#resultdurationms), formatted as `(done in 29ms)`Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 1274–1314why, one step back12741275#### verboseObject.escapedCommand12761277_Type_: `string`12781279The file and [arguments](input.md#command-arguments) that were run. This is the same as [`result.escapedCommand`](#resultescapedcommand).12801281#### verboseObject.options12821283_Type_: [`Options`](#options-1) or [`SyncOptions`](#options-1)12841285The [options](#options-1) passed to the subprocess.12861287#### verboseObject.commandId12881289_Type_: `string`12901291Serial number identifying the subprocess within the current process. It is incremented from `'0'`.12921293This is helpful when multiple subprocesses are running at the same time.12941295This 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.12961297#### verboseObject.timestamp12981299_Type_: `Date`13001301Event date/time.13021303#### verboseObject.result13041305_Type_: [`Result`](#result), [`SyncResult`](#result) or `undefined`13061307Subprocess [result](#result).13081309This is `undefined` if [`verboseObject.type`](#verboseobjecttype) is `'command'`, `'output'` or `'ipc'`.13101311#### verboseObject.piped13121313_Type_: `boolean`1314Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
line 1315why, one step back1315Whether this subprocess is the destination of another subprocess' [`pipe()`](#subprocesspipefile-arguments-options) method. This is `true` when it was spawned using the [template string](pipe.md#template-string-syntax) or [array](pipe.md#array-syntax) syntax, `false` otherwise.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1316–1354why, one step back13161317## Transform options13181319A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.13201321A transform is either a [generator function](#transformoptionstransform) or a plain object with the following members.13221323[More info.](transform.md)13241325### transformOptions.transform13261327_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`13281329Map or [filter](transform.md#filtering) the [input](input.md) or [output](output.md) of the subprocess.13301331More info [here](transform.md#summary) and [there](transform.md#sharing-state).13321333### transformOptions.final13341335_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`13361337Create additional lines after the last one.13381339[More info.](transform.md#finalizing)13401341### transformOptions.binary13421343_Type:_ `boolean`\1344_Default:_ `false`13451346If `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.13471348[More info.](binary.md#transforms)13491350### transformOptions.preserveNewlines13511352_Type:_ `boolean`\1353_Default:_ `false`1354Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8
line 1355why, one step back1355If `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produce a single line.100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1356–1371why, one step back13561357[More info.](lines.md#transforms)13581359### transformOptions.objectMode13601361_Type:_ `boolean`\1362_Default:_ `false`13631364If `true`, allow [`transformOptions.transform`](#transformoptionstransform) and [`transformOptions.final`](#transformoptionsfinal) to return any type, not just `string` or `Uint8Array`.13651366[More info.](transform.md#object-mode)13671368<hr>13691370[**Previous**: 🔍 Differences with Bash and zx](bash.md)\1371[**Top**: Table of contents](../readme.md#documentation)