readme.md
This file
Path
readme.md
1,225 lines · 48.7 KiB · Markdown
Last changed by
Add support for `all` option to `execaSync()` (#956)ehmickybefore adoption63b5ac4
History of this fileTake it
The walk stopped after 200 commits: lines older than 4fb84f0 point at it.
Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1–33why, 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[](https://codecov.io/gh/sindresorhus/execa)89> Process execution for humans1011<br>1213---1415<div align="center">16 <p>17 <p>18 <sup>19 <a href="https://github.com/sponsors/sindresorhus">Sindre's open source work is supported by the community</a>20 </sup>21 </p>22 <sup>Special thanks to:</sup>23 <br>24 <br>25 <a href="https://transloadit.com?utm_source=sindresorhus&utm_medium=referral&utm_campaign=sponsorship&utm_content=execa">26 <picture>27 <source width="360" media="(prefers-color-scheme: dark)" srcset="https://sindresorhus.com/assets/thanks/transloadit-logo-dark.svg">28 <source width="360" media="(prefers-color-scheme: light)" srcset="https://sindresorhus.com/assets/thanks/transloadit-logo.svg">29 <img width="360" src="https://sindresorhus.com/assets/thanks/transloadit-logo.svg" alt="Transloadit logo">30 </picture>31 </a>32 <br>33 <br>Meta tweaksSindre Sorhusbefore adoption1915060
lines 34–38why, one step back34 <a href="https://coderabbit.ai?utm_source=sindre&utm_medium=execa">35 <img width="300" src="https://sindresorhus.com/assets/thanks/coderabbit-logo.png" alt="CodeRabbit logo">36 </a>37 <br>38 <br>Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 39–49why, one step back39 </p>40</div>4142---4344<br>4546## Why4748This package improves [`child_process`](https://nodejs.org/api/child_process.html) methods with:49Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 50–51why, one step back50- [Promise interface](#execafile-arguments-options).51- [Script interface](docs/scripts.md) and [template strings](#template-string-syntax), like `zx`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 52–53why, one step back52- Improved [Windows support](https://github.com/IndigoUnited/node-cross-spawn#why), including [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) binaries.53- Executes [locally installed binaries](#preferlocal) without `npx`.Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 54why, one step back54- [Cleans up](#cleanup) subprocesses when the current process ends.Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce
line 55why, one step back55- Redirect [`stdin`](#stdin)/[`stdout`](#stdout-1)/[`stderr`](#stderr-1) from/to files, streams, iterables, strings, `Uint8Array` or [objects](docs/transform.md#object-mode).Line-wise transforms (#699)ehmickybefore adoption6dd804f
line 56why, one step back56- [Transform](docs/transform.md) `stdin`/`stdout`/`stderr` with simple functions.Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 57–58why, one step back57- Iterate over [each text line](docs/transform.md#binary-data) output by the subprocess.58- [Fail-safe subprocess termination](#forcekillafterdelay).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 59–60why, one step back59- Get [interleaved output](#all) from `stdout` and `stderr` similar to what is printed on the terminal.60- [Strips the final newline](#stripfinalnewline) from the output so you don't have to do `stdout.trim()`.Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 61why, one step back61- Convenience methods to pipe subprocesses' [input](#input) and [output](#redirect-output-to-a-file).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 62–83why, one step back62- [Verbose mode](#verbose-mode) for debugging.63- More descriptive errors.64- Higher max buffer: 100 MB instead of 1 MB.6566## Install6768```sh69npm install execa70```7172## Usage7374### Promise interface7576```js77import {execa} from 'execa';7879const {stdout} = await execa('echo', ['unicorns']);80console.log(stdout);81//=> 'unicorns'82```83Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 84why, one step back84#### Global/shared optionsRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 85why, one step back85Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 86–87why, one step back86```js87import {execa as execa_} from 'execa';Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 88why, one step back88Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 89–96why, one step back89const execa = execa_({verbose: 'full'});9091await execa('echo', ['unicorns']);92//=> 'unicorns'93```9495### Template string syntax96Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 97–99why, one step back97#### Basic9899```jsAllow template strings with all methods (#933)ehmickybefore adoption8074d85
line 100why, one step back100import {execa} from 'execa';Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 101why, one step back101Refactor tests (#934)ehmickybefore adoption52c4bde
line 102why, one step back102const arg = 'unicorns';Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 103–105why, one step back103const {stdout} = await execa`echo ${arg} & rainbows!`;104console.log(stdout);105//=> 'unicorns & rainbows!'Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 106–110why, one step back106```107108#### Multiple arguments109110```jsAllow template strings with all methods (#933)ehmickybefore adoption8074d85
line 111why, one step back111import {execa} from 'execa';Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 112–113why, one step back112113const args = ['unicorns', '&', 'rainbows!'];Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 114why, one step back114const {stdout} = await execa`echo ${args}`;Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 115–121why, one step back115console.log(stdout);116//=> 'unicorns & rainbows!'117```118119#### With options120121```jsAllow template strings with all methods (#933)ehmickybefore adoption8074d85
line 122why, one step back122import {execa} from 'execa';Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 123why, one step back123Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 124why, one step back124await execa({verbose: 'full'})`echo unicorns`;Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 125–127why, one step back125//=> 'unicorns'126```127Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 128why, one step back128### ScriptsRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 129why, one step back129Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 130why, one step back130For more information about Execa scripts, please see [this page](docs/scripts.md).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 131why, one step back131Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 132why, one step back132#### BasicRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 133why, one step back133`.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562
lines 134–136why, one step back134```js135import {$} from 'execa';136Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 137–138why, one step back137const branch = await $`git branch --show-current`;138await $`dep deploy --branch=${branch}`;`.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562
lines 139–140why, one step back139```140Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 141–148why, one step back141#### Verbose mode142143```sh144> node file.js145unicorns146rainbows147148> NODE_DEBUG=execa node file.jsPrint output with `verbose` option (#884)ehmickybefore adoption6fda30f
line 149why, one step back149[19:49:00.360] [0] $ echo unicornsRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 150why, one step back150unicornsPrint process completion with verbose option (#887)ehmickybefore adoption7264bcf
line 151why, one step back151[19:49:00.383] [0] √ (done in 23ms)Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
line 152why, one step back152[19:49:00.383] [1] $ echo rainbowsRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 153why, one step back153rainbowsPrint process completion with verbose option (#887)ehmickybefore adoption7264bcf
line 154why, one step back154[19:49:00.404] [1] √ (done in 21ms)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 155–164why, one step back155```156157### Input/output158159#### Redirect output to a file160161```js162import {execa} from 'execa';163164// Similar to `echo unicorns > stdout.txt` in BashOnly allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305
line 165why, one step back165await execa('echo', ['unicorns'], {stdout: {file: 'stdout.txt'}});Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 166–167why, one step back166167// Similar to `echo unicorns 2> stdout.txt` in BashOnly allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305
line 168why, one step back168await execa('echo', ['unicorns'], {stderr: {file: 'stderr.txt'}});Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 169–170why, one step back169170// Similar to `echo unicorns &> stdout.txt` in BashOnly allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305
line 171why, one step back171await execa('echo', ['unicorns'], {stdout: {file: 'all.txt'}, stderr: {file: 'all.txt'}});Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 172–184why, one step back172```173174#### Redirect input from a file175176```js177import {execa} from 'execa';178179// Similar to `cat < stdin.txt` in Bash180const {stdout} = await execa('cat', {inputFile: 'stdin.txt'});181console.log(stdout);182//=> 'unicorns'183```184Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 185why, one step back185#### Save and pipe output from a subprocessRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 186–189why, one step back186187```js188import {execa} from 'execa';189Only allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305
line 190why, one step back190const {stdout} = await execa('echo', ['unicorns'], {stdout: ['pipe', 'inherit']});Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 191–195why, one step back191// Prints `unicorns`192console.log(stdout);193// Also returns 'unicorns'194```195Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 196why, one step back196#### Pipe multiple subprocessesRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 197–200why, one step back197198```js199import {execa} from 'execa';200Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 201–202why, one step back201// Similar to `npm run build | sort | head -n2` in Bash202const {stdout, pipedFrom} = await execa('npm', ['run', 'build'])Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 203–204why, one step back203 .pipe('sort')204 .pipe('head', ['-n2']);Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 205–207why, one step back205console.log(stdout); // Result of `head -n2`206console.log(pipedFrom[0]); // Result of `sort`207console.log(pipedFrom[0].pipedFrom[0]); // Result of `npm run build`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 208–209why, one step back208```209Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 210–219why, one step back210#### Pipe with template strings211212```js213import {execa} from 'execa';214215await execa`npm run build`216 .pipe`sort`217 .pipe`head -n2`;218```219Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
lines 220–224why, one step back220#### Iterate over output lines221222```js223import {execa} from 'execa';224Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 225why, one step back225for await (const line of execa`npm run build`)) {Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
lines 226–231why, one step back226 if (line.includes('ERROR')) {227 console.log(line);228 }229}230```231Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 232–242why, one step back232### Handling Errors233234```js235import {execa} from 'execa';236237// Catching an error238try {239 await execa('unknown', ['command']);240} catch (error) {241 console.log(error);242 /*Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 243–246why, one step back243 ExecaError: Command failed with ENOENT: unknown command244 spawn unknown ENOENT245 at ...246 at ... {Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 247why, one step back247 shortMessage: 'Command failed with ENOENT: unknown command\nspawn unknown ENOENT',Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 248–250why, one step back248 originalMessage: 'spawn unknown ENOENT',249 command: 'unknown command',250 escapedCommand: 'unknown command',Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
lines 251–252why, one step back251 cwd: '/path/to/cwd',252 durationMs: 28.217566,Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 253–255why, one step back253 failed: true,254 timedOut: false,255 isCanceled: false,Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 256why, one step back256 isTerminated: false,Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 257why, one step back257 code: 'ENOENT',Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
lines 258–261why, one step back258 stdout: '',259 stderr: '',260 stdio: [undefined, '', ''],261 pipedFrom: []Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 262–270why, one step back262 [cause]: Error: spawn unknown ENOENT263 at ...264 at ... {265 errno: -2,266 code: 'ENOENT',267 syscall: 'spawn unknown',268 path: 'unknown',269 spawnargs: [ 'command' ]270 }Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 271–281why, one step back271 }272 */273}274```275276## API277278### Methods279280#### execa(file, arguments?, options?)281Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 282–283why, one step back282`file`: `string | URL`\283`arguments`: `string[]`\Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 284why, one step back284`options`: [`Options`](#options)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 285why, one step back285_Returns_: [`Subprocess`](#subprocess)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 286why, one step back286Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 287–288why, one step back287Executes a command using `file ...arguments`.288Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 289why, one step back289Arguments are [automatically escaped](#shell-syntax). They can contain any character, including spaces, tabs and newlines.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 290why, one step back290Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 291–292why, one step back291#### execa\`command\`292#### execa(options)\`command\`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 293why, one step back293Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 294why, one step back294`command`: `string`\Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 295why, one step back295`options`: [`Options`](#options)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 296why, one step back296_Returns_: [`Subprocess`](#subprocess)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 297why, one step back297Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 298why, one step back298Executes a command. `command` is a [template string](#template-string-syntax) and includes both the `file` and its `arguments`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 299why, one step back299Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 300why, one step back300The `command` template string can inject any `${value}` with the following types: string, number, [`subprocess`](#subprocess) or an array of those types. For example: `` execa`echo one ${'two'} ${3} ${['four', 'five']}` ``. For `${subprocess}`, the subprocess's [`stdout`](#stdout) is used.Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 301why, one step back301Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 302why, one step back302Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces, tabs and newlines must use `${}` like `` execa`echo ${'has space'}` ``.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 303why, one step back303Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 304why, one step back304The `command` template string can use [multiple lines and indentation](docs/scripts.md#multiline-commands).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 305why, one step back305Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 306why, one step back306#### execa(options)Allow newlines in `$` (#843)ehmickybefore adoption1315486
line 307why, one step back307Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 308–309why, one step back308`options`: [`Options`](#options)\309_Returns_: [`execa`](#execafile-arguments-options)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 310why, one step back310Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 311why, one step back311Returns a new instance of Execa but with different default [`options`](#options). Consecutive calls are merged to previous ones.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 312why, one step back312Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 313why, one step back313This allows setting global options or [sharing options](#globalshared-options) between multiple commands.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 314why, one step back314Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 315–316why, one step back315#### execaSync(file, arguments?, options?)316#### execaSync\`command\`Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 317why, one step back317Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 318why, one step back318Same as [`execa()`](#execafile-arguments-options) but synchronous.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 319why, one step back319Improve documentation of `execaSync()` (#935)ehmickybefore adoption1c12be9
line 320why, one step back320Returns or throws a [`subprocessResult`](#subprocessResult). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`.pipe()`](#pipefile-arguments-options), [`.iterable()`](#iterablereadableoptions), [`.readable()`](#readablereadableoptions), [`.writable()`](#writablewritableoptions), [`.duplex()`](#duplexduplexoptions) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 321why, one step back321Add support for `all` option to `execaSync()` (#956)ehmickybefore adoption63b5ac4
line 322why, one step back322Cannot use the following options: [`cleanup`](#cleanup), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`cancelSignal`](#cancelsignal) and [`forceKillAfterDelay`](#forcekillafterdelay). [`result.all`](#all-1) is not interleaved. Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [`stdio`](#stdio-1) options cannot be [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async [transform](docs/transform.md), a [`Duplex`](docs/transform.md#duplextransform-streams), or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 323–328why, one step back323324#### $(file, arguments?, options?)325326`file`: `string | URL`\327`arguments`: `string[]`\328`options`: [`Options`](#options)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 329why, one step back329_Returns_: [`Subprocess`](#subprocess)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 330why, one step back330Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 331why, one step back331Same as [`execa()`](#execafile-arguments-options) but using the [`stdin: 'inherit'`](#stdin) and [`preferLocal: true`](#preferlocal) options.Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 332why, one step back332Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 333why, one step back333Just like `execa()`, this can use the [template string syntax](#execacommand) or [bind options](#execaoptions). It can also be [run synchronously](#execasyncfile-arguments-options) using `$.sync()` or `$.s()`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 334why, one step back334Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 335why, one step back335This is the preferred method when executing multiple commands in a script file. For more information, please see [this page](docs/scripts.md).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 336why, one step back336Add `node` option (#804)ehmickybefore adoption663136b
lines 337–338why, one step back337#### execaNode(scriptPath, arguments?, options?)338Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 339why, one step back339`scriptPath`: `string | URL`\Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 340why, one step back340`arguments`: `string[]`\Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 341why, one step back341`options`: [`Options`](#options)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 342why, one step back342_Returns_: [`Subprocess`](#subprocess)Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 343why, one step back343Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 344why, one step back344Same as [`execa()`](#execafile-arguments-options) but using the [`node: true`](#node) option.Add `node` option (#804)ehmickybefore adoption663136b
lines 345–346why, one step back345Executes a Node.js file using `node scriptPath ...arguments`.346Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 347–348why, one step back347Just like `execa()`, this can use the [template string syntax](#execacommand) or [bind options](#execaoptions).348Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 349why, one step back349This is the preferred method when executing Node.js files.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 350why, one step back350Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 351why, one step back351#### execaCommand(command, options?)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 352why, one step back352Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 353–355why, one step back353`command`: `string`\354`options`: [`Options`](#options)\355_Returns_: [`Subprocess`](#subprocess)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 356why, one step back356Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 357why, one step back357[`execa`](#execafile-arguments-options) with the [template string syntax](#execacommand) allows the `file` or the `arguments` to be user-defined (by injecting them with `${}`). However, if _both_ the `file` and the `arguments` are user-defined, _and_ those are supplied as a single string, then `execaCommand(command)` must be used instead.Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd
line 358why, one step back358Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 359why, one step back359This is only intended for very specific cases, such as a REPL. This should be avoided otherwise.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 360why, one step back360Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 361–364why, one step back361Just like `execa()`, this can [bind options](#execaoptions). It can also be [run synchronously](#execasyncfile-arguments-options) using `execaCommandSync()`.362363Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces must be escaped with a backslash like `execaCommand('echo has\\ space')`.364Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 365–368why, one step back365### Shell syntax366367For all the [methods above](#methods), no shell interpreter (Bash, cmd.exe, etc.) is used unless the [`shell` option](#shell) is set. This means shell-specific characters and expressions (`$variable`, `&&`, `||`, `;`, `|`, etc.) have no special meaning and do not need to be escaped.368Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 369why, one step back369### subprocessRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 370–371why, one step back370371The return value of all [asynchronous methods](#methods) is both:Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 372why, one step back372- a `Promise` resolving or rejecting with a [`subprocessResult`](#subprocessResult).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 373–382why, one step back373- a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following additional methods and properties.374375#### all376377Type: `ReadableStream | undefined`378379Stream [combining/interleaving](#ensuring-all-output-is-interleaved) [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).380381This is `undefined` if either:382- the [`all` option](#all-2) is `false` (the default value)Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 383why, one step back383- both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 384why, one step back384Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 385why, one step back385#### pipe(file, arguments?, options?)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 386why, one step back386Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 387–388why, one step back387`file`: `string | URL`\388`arguments`: `string[]`\Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 389why, one step back389`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 390why, one step back390_Returns_: [`Promise<SubprocessResult>`](#subprocessresult)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 391why, one step back391Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 392why, one step back392[Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the subprocess' `stdout` to a second Execa subprocess' `stdin`. This resolves with that second subprocess' [result](#subprocessresult). If either subprocess is rejected, this is rejected with that subprocess' [error](#execaerror) instead.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 393why, one step back393Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 394why, one step back394This 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.Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 395why, one step back395Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 396why, one step back396This can be called multiple times to chain a series of subprocesses.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 397why, one step back397Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 398why, one step back398Multiple subprocesses can be piped to the same subprocess. Conversely, the same subprocess can be piped to multiple other subprocesses.`.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562
line 399why, one step back399Fix Markdown typo (#869)ehmickybefore adoptionc8ba426
lines 400–401why, one step back400#### pipe\`command\`401#### pipe(options)\`command\``.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562
line 402why, one step back402Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 403why, one step back403`command`: `string`\Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 404why, one step back404`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 405why, one step back405_Returns_: [`Promise<SubprocessResult>`](#subprocessresult)`.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562
line 406why, one step back406Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 407why, one step back407Like [`.pipe(file, arguments?, options?)`](#pipefile-arguments-options) but using a [`command` template string](docs/scripts.md#piping-stdout-to-another-command) instead. This follows the same syntax as `execa` [template strings](#execacommand).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 408why, one step back408Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 409why, one step back409#### pipe(secondSubprocess, pipeOptions?)Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 410why, one step back410Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 411why, one step back411`secondSubprocess`: [`execa()` return value](#subprocess)\Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 412why, one step back412`pipeOptions`: [`PipeOptions`](#pipeoptions)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 413why, one step back413_Returns_: [`Promise<SubprocessResult>`](#subprocessresult)Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 414why, one step back414Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 415why, one step back415Like [`.pipe(file, arguments?, options?)`](#pipefile-arguments-options) but using the [return value](#subprocess) of another `execa()` call instead.Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 416why, one step back416Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 417why, one step back417This is the most advanced method to pipe subprocesses. It is useful in specific cases, such as piping multiple subprocesses to the same subprocess.Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 418why, one step back418Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 419why, one step back419##### pipeOptionsOnly allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305
line 420why, one step back420Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 421–424why, one step back421Type: `object`422423##### pipeOptions.from424Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 425why, one step back425Type: `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 426–427why, one step back426Default: `"stdout"`427Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 428why, one step back428Which stream to pipe from the source subprocess. A file descriptor like `"fd3"` can also be passed.Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 429–430why, one step back429430`"all"` pipes both `stdout` and `stderr`. This requires the [`all` option](#all-2) to be `true`.Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2
lines 431–433why, one step back431432##### pipeOptions.to433Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 434why, one step back434Type: `"stdin" | "fd3" | "fd4" | ...`\Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2
lines 435–436why, one step back435Default: `"stdin"`436Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 437why, one step back437Which stream to pipe to the destination subprocess. A file descriptor like `"fd3"` can also be passed.Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 438why, one step back438Rename `signal` option to `unpipeSignal` (#852)ehmickybefore adoption9dc1141
line 439why, one step back439##### pipeOptions.unpipeSignalImprove piping processes (#834)ehmickybefore adoption1a47ea2
lines 440–442why, one step back440441Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)442Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 443why, one step back443Unpipe the subprocess when the signal aborts.Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 444why, one step back444Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 445why, one step back445The [`.pipe()`](#pipefile-arguments-options) method will be rejected with a cancellation error.Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 446why, one step back446Add `.kill(signal, error)` (#836)ehmickybefore adoption30a662d
lines 447–448why, one step back447#### kill(signal, error?)448#### kill(error?)Add `.kill(error)` (#811)ehmickybefore adoption9cbb817
line 449why, one step back449Add `.kill(signal, error)` (#836)ehmickybefore adoption30a662d
lines 450–451why, one step back450`signal`: `string | number`\451`error`: `Error`\Add `.kill(error)` (#811)ehmickybefore adoption9cbb817
lines 452–453why, one step back452_Returns_: `boolean`453Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 454why, one step back454Sends a [signal](https://nodejs.org/api/os.html#signal-constants) to the subprocess. The default signal is the [`killSignal`](#killsignal) option. `killSignal` defaults to `SIGTERM`, which [terminates](#isterminated) the subprocess.Add `.kill(error)` (#811)ehmickybefore adoption9cbb817
line 455why, one step back455Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 456why, one step back456This returns `false` when the signal could not be sent, for example when the subprocess has already exited.Add `.kill(error)` (#811)ehmickybefore adoption9cbb817
line 457why, one step back457Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 458why, one step back458When an error is passed as argument, it is set to the subprocess' [`error.cause`](#cause). 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).Add `.kill(error)` (#811)ehmickybefore adoption9cbb817
lines 459–461why, one step back459460[More info.](https://nodejs.org/api/child_process.html#subprocesskillsignal)461Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
lines 462–476why, one step back462#### [Symbol.asyncIterator]()463464_Returns_: `AsyncIterable`465466Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.467468The iteration waits for the subprocess to end. It throws if the subprocess [fails](#subprocessresult). This means you do not need to `await` the subprocess' [promise](#subprocess).469470#### iterable(readableOptions?)471472`readableOptions`: [`ReadableOptions`](#readableoptions)\473_Returns_: `AsyncIterable`474475Same as [`subprocess[Symbol.asyncIterator]`](#symbolasynciterator) except [options](#readableoptions) can be provided.476Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 477why, one step back477#### readable(readableOptions?)Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 478why, one step back478Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 479why, one step back479`readableOptions`: [`ReadableOptions`](#readableoptions)\Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 480–485why, one step back480_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream481482Converts the subprocess to a readable stream.483484Unlike [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), the stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess [fails](#subprocessresult). This means you do not need to `await` the subprocess' [promise](#subprocess). On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options), [`await pipeline(..., stream)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) or [`await text(stream)`](https://nodejs.org/api/webstreams.html#streamconsumerstextstream) which throw an exception when the stream errors.485Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 486why, one step back486Before using this method, please first consider the [`stdin`](#stdin)/[`stdout`](#stdout-1)/[`stderr`](#stderr-1)/[`stdio`](#stdio-1) options, [`subprocess.pipe()`](#pipefile-arguments-options) or [`subprocess.iterable()`](#iterablereadableoptions).Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 487why, one step back487Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 488why, one step back488#### writable(writableOptions?)Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 489why, one step back489Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 490why, one step back490`writableOptions`: [`WritableOptions`](#writableoptions)\Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 491–496why, one step back491_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream492493Converts the subprocess to a writable stream.494495Unlike [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin), the stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess [fails](#subprocessresult). This means you do not need to `await` the subprocess' [promise](#subprocess). On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options) or [`await pipeline(stream, ...)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) which throw an exception when the stream errors.496Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 497why, one step back497Before using this method, please first consider the [`stdin`](#stdin)/[`stdout`](#stdout-1)/[`stderr`](#stderr-1)/[`stdio`](#stdio-1) options or [`subprocess.pipe()`](#pipefile-arguments-options).Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 498why, one step back498Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 499why, one step back499#### duplex(duplexOptions?)Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 500why, one step back500Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 501why, one step back501`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 502–507why, one step back502_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream503504Converts the subprocess to a duplex stream.505506The stream waits for the subprocess to end and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess [fails](#subprocessresult). This means you do not need to `await` the subprocess' [promise](#subprocess). On the other hand, you do need to handle to the stream `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options), [`await pipeline(..., stream, ...)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) or [`await text(stream)`](https://nodejs.org/api/webstreams.html#streamconsumerstextstream) which throw an exception when the stream errors.507Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 508why, one step back508Before using this method, please first consider the [`stdin`](#stdin)/[`stdout`](#stdout-1)/[`stderr`](#stderr-1)/[`stdio`](#stdio-1) options, [`subprocess.pipe()`](#pipefile-arguments-options) or [`subprocess.iterable()`](#iterablereadableoptions).Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 509why, one step back509Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 510why, one step back510##### readableOptionsAdd `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 511–513why, one step back511512Type: `object`513Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 514why, one step back514##### readableOptions.fromAdd `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 515why, one step back515Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 516why, one step back516Type: `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 517–518why, one step back517Default: `"stdout"`518Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 519why, one step back519Which stream to read from the subprocess. A file descriptor like `"fd3"` can also be passed.Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 520–522why, one step back520521`"all"` reads both `stdout` and `stderr`. This requires the [`all` option](#all-2) to be `true`.522Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 523why, one step back523##### readableOptions.binaryAdd `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 524why, one step back524Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
lines 525–526why, one step back525Type: `boolean`\526Default: `false` with [`.iterable()`](#iterablereadableoptions), `true` with [`.readable()`](#readablereadableoptions)/[`.duplex()`](#duplexduplexoptions)Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 527why, one step back527Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
lines 528–529why, one step back528If `false`, the stream iterates over lines. Each line is a string. Also, the stream is in [object mode](https://nodejs.org/api/stream.html#object-mode).529Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 530why, one step back530If `true`, the stream iterates over arbitrary chunks of data. Each line is an `Uint8Array` (with [`.iterable()`](#iterablereadableoptions)) or a [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) (otherwise).Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 531why, one step back531Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 532why, one step back532This is always `true` when the [`encoding` option](#encoding) is binary.Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 533why, one step back533Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
lines 534–536why, one step back534##### readableOptions.preserveNewlines535536Type: `boolean`\Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 537why, one step back537Default: `false` with [`.iterable()`](#iterablereadableoptions), `true` with [`.readable()`](#readablereadableoptions)/[`.duplex()`](#duplexduplexoptions)Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
lines 538–546why, one step back538539If both this option and the [`binary` option](#readableoptionsbinary) is `false`, newlines are stripped from each line.540541##### writableOptions542543Type: `object`544545##### writableOptions.to546Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 547why, one step back547Type: `"stdin" | "fd3" | "fd4" | ...`\Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 548–549why, one step back548Default: `"stdin"`549Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 550why, one step back550Which stream to write to the subprocess. A file descriptor like `"fd3"` can also be passed.Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 551why, one step back551Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 552why, one step back552### SubprocessResultRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 553–555why, one step back553554Type: `object`555Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 556why, one step back556Result of a subprocess execution.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 557why, one step back557Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 558why, one step back558When the subprocess [fails](#failed), it is rejected with an [`ExecaError`](#execaerror) instead.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 559–565why, one step back559560#### command561562Type: `string`563564The file and arguments that were run, for logging purposes.565Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 566why, one step back566This is not escaped and should not be executed directly as a subprocess, including using [`execa()`](#execafile-arguments-options) or [`execaCommand()`](#execacommandcommand-options).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 567–571why, one step back567568#### escapedCommand569570Type: `string`571Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 572why, one step back572Same as [`command`](#command) but escaped.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 573why, one step back573Better escaping of `result.escapedCommand` (#875)ehmickybefore adoption7b044bb
lines 574–576why, one step back574Unlike `command`, control characters are escaped, which makes it safe to print in a terminal.575576This can also be copied and pasted into a shell, for debugging purposes.Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 577why, one step back577Since the escaping is fairly basic, this should not be executed directly as a subprocess, including using [`execa()`](#execafile-arguments-options) or [`execaCommand()`](#execacommandcommand-options).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 578why, one step back578Re-order return value properties (#801)ehmickybefore adoption72836f3
line 579why, one step back579#### cwdRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 580why, one step back580Re-order return value properties (#801)ehmickybefore adoption72836f3
line 581why, one step back581Type: `string`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 582why, one step back582Improve `cwd` option (#803)ehmickybefore adoption2fd9351
line 583why, one step back583The [current directory](#cwd-1) in which the command was run.Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
lines 584–588why, one step back584585#### durationMs586587Type: `number`588Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 589why, one step back589Duration of the subprocess, in milliseconds.Document and type `exitCode` being `undefined` (#680)ehmickybefore adoption95e5754
line 590why, one step back590Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 591–592why, one step back591#### stdout592Line-wise standard streams (#741)ehmickybefore adoption479d12e
line 593why, one step back593Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 594why, one step back594Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 595why, one step back595The output of the subprocess on `stdout`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 596why, one step back596Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 597why, one step back597This is `undefined` if the [`stdout`](#stdout-1) option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the [`lines` option](#lines) is `true`, or if the `stdout` option is a [transform in object mode](docs/transform.md#object-mode).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 598–600why, one step back598599#### stderr600Line-wise standard streams (#741)ehmickybefore adoption479d12e
line 601why, one step back601Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 602why, one step back602Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 603why, one step back603The output of the subprocess on `stderr`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 604why, one step back604Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 605why, one step back605This is `undefined` if the [`stderr`](#stderr-1) option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the [`lines` option](#lines) is `true`, or if the `stderr` option is a [transform in object mode](docs/transform.md#object-mode).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 606–608why, one step back606607#### all608Line-wise standard streams (#741)ehmickybefore adoption479d12e
line 609why, one step back609Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 610why, one step back610Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 611why, one step back611The output of the subprocess with `stdout` and `stderr` [interleaved](#ensuring-all-output-is-interleaved).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 612–614why, one step back612613This is `undefined` if either:614- the [`all` option](#all-2) is `false` (the default value)Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 615why, one step back615- both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 616why, one step back616Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 617why, one step back617This is an array if the [`lines` option](#lines) is `true`, or if either the `stdout` or `stderr` option is a [transform in object mode](docs/transform.md#object-mode).Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce
line 618why, one step back618Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
lines 619–620why, one step back619#### stdio620Line-wise standard streams (#741)ehmickybefore adoption479d12e
line 621why, one step back621Type: `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
line 622why, one step back622Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 623why, one step back623The output of the subprocess on [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [other file descriptors](#stdio-1).Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
line 624why, one step back624Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 625why, one step back625Items are `undefined` when their corresponding [`stdio`](#stdio-1) option is set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). Items are arrays when their corresponding `stdio` option is a [transform in object mode](docs/transform.md#object-mode).Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
line 626why, one step back626Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 627–630why, one step back627#### failed628629Type: `boolean`630Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 631why, one step back631Whether the subprocess failed to run.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 632–636why, one step back632633#### timedOut634635Type: `boolean`636Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 637why, one step back637Whether the subprocess timed out.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 638–642why, one step back638639#### isCanceled640641Type: `boolean`642Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 643why, one step back643Whether the subprocess was canceled using the [`cancelSignal`](#cancelsignal) option.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 644–648why, one step back644645#### isTerminated646647Type: `boolean`648Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 649why, one step back649Whether the subprocess was terminated by a signal (like `SIGTERM`) sent by either:Improve process termination (#724)ehmickybefore adoption1c48d37
lines 650–651why, one step back650- The current process.651- Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 652why, one step back652Re-order return value properties (#801)ehmickybefore adoption72836f3
lines 653–656why, one step back653#### exitCode654655Type: `number | undefined`656Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 657why, one step back657The numeric exit code of the subprocess that was run.Re-order return value properties (#801)ehmickybefore adoption72836f3
line 658why, one step back658Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 659why, one step back659This is `undefined` when the subprocess could not be spawned or was terminated by a [signal](#signal).Re-order return value properties (#801)ehmickybefore adoption72836f3
line 660why, one step back660Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 661–664why, one step back661#### signal662663Type: `string | undefined`664Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 665why, one step back665The name of the signal (like `SIGTERM`) that terminated the subprocess, sent by either:Improve process termination (#724)ehmickybefore adoption1c48d37
lines 666–667why, one step back666- The current process.667- Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 668why, one step back668Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 669why, one step back669If a signal terminated the subprocess, this property is defined and included in the error message. Otherwise it is `undefined`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 670–674why, one step back670671#### signalDescription672673Type: `string | undefined`674Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 675why, one step back675A human-friendly description of the signal that was used to terminate the subprocess. For example, `Floating point arithmetic error`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 676why, one step back676Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 677why, one step back677If 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.Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 678–680why, one step back678679#### pipedFrom680Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 681why, one step back681Type: [`Array<SubprocessResult | ExecaError>`](#subprocessresult)Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 682why, one step back682Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 683why, one step back683Results of the other subprocesses that were [piped](#pipe-multiple-subprocesses) into this subprocess. This is useful to inspect a series of subprocesses piped with each other.Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 684why, one step back684Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 685why, one step back685This array is initially empty and is populated each time the [`.pipe()`](#pipefile-arguments-options) method resolves.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 686why, one step back686Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 687–736why, one step back687### ExecaError688### ExecaSyncError689690Type: `Error`691692Exception thrown when the subprocess [fails](#failed), either:693- its [exit code](#exitcode) is not `0`694- it was [terminated](#isterminated) with a [signal](#signal), including [`.kill()`](#killerror)695- [timing out](#timedout)696- [being canceled](#iscanceled)697- there's not enough memory or there are already too many subprocesses698699This has the same shape as [successful results](#subprocessresult), with the following additional properties.700701#### message702703Type: `string`704705Error message when the subprocess failed to run. In addition to the [underlying error message](#originalMessage), it also contains some information related to why the subprocess errored.706707The subprocess [`stderr`](#stderr), [`stdout`](#stdout) and other [file descriptors' output](#stdio) are appended to the end, separated with newlines and not interleaved.708709#### shortMessage710711Type: `string`712713This is the same as the [`message` property](#message) except it does not include the subprocess [`stdout`](#stdout)/[`stderr`](#stderr)/[`stdio`](#stdio).714715#### originalMessage716717Type: `string | undefined`718719Original error message. This is the same as the `message` property excluding the subprocess [`stdout`](#stdout)/[`stderr`](#stderr)/[`stdio`](#stdio) and some additional information added by Execa.720721This exists only if the subprocess exited due to an `error` event or a timeout.722723#### cause724725Type: `unknown | undefined`726727Underlying error, if there is one. For example, this is set by [`.kill(error)`](#killerror).728729This is usually an `Error` instance.730731#### code732733Type: `string | undefined`734735Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.736Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 737–740why, one step back737### options738739Type: `object`740Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 741why, one step back741This lists all Execa options, including some options which are the same as for [`child_process#spawn()`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)/[`child_process#exec()`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 742why, one step back742Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 743–744why, one step back743#### reject744Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 745–747why, one step back745Type: `boolean`\746Default: `true`747Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 748why, one step back748Setting this to `false` resolves the promise with the [error](#execaerror) instead of rejecting it.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 749why, one step back749Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 750–766why, one step back750#### shell751752Type: `boolean | string | URL`\753Default: `false`754755If `true`, runs `file` inside of a shell. Uses `/bin/sh` on UNIX and `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.756757We recommend against using this option since it is:758- not cross-platform, encouraging shell-specific syntax.759- slower, because of the additional shell interpretation.760- unsafe, potentially allowing command injection.761762#### cwd763764Type: `string | URL`\765Default: `process.cwd()`766Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 767why, one step back767Current working directory of the subprocess.Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 768why, one step back768Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
line 769why, one step back769This is also used to resolve the [`nodePath`](#nodepath) option when it is a relative path.Improve `cwd` option (#803)ehmickybefore adoption2fd9351
line 770why, one step back770Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 771–777why, one step back771#### env772773Type: `object`\774Default: `process.env`775776Environment key-value pairs.777Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 778why, one step back778Unless the [`extendEnv` option](#extendenv) is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 779–784why, one step back779780#### extendEnv781782Type: `boolean`\783Default: `true`784Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 785why, one step back785If `true`, the subprocess uses both the [`env` option](#env) and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 786–787why, one step back786If `false`, only the `env` option is used, not `process.env`.787Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 788–790why, one step back788#### preferLocal789790Type: `boolean`\Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 791why, one step back791Default: `true` with [`$`](#file-arguments-options), `false` otherwiseRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 792–802why, one step back792793Prefer locally installed binaries when looking for a binary to execute.\794If you `$ npm install foo`, you can then `execa('foo')`.795796#### localDir797798Type: `string | URL`\799Default: `process.cwd()`800801Preferred path to find locally installed binaries in (use with `preferLocal`).802Add `node` option (#804)ehmickybefore adoption663136b
line 803why, one step back803#### nodeRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 804why, one step back804Add `node` option (#804)ehmickybefore adoption663136b
lines 805–806why, one step back805Type: `boolean`\806Default: `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwiseRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 807why, one step back807Add `node` option (#804)ehmickybefore adoption663136b
line 808why, one step back808If `true`, runs with Node.js. The first argument must be a Node.js file.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 809why, one step back809Add `node` option (#804)ehmickybefore adoption663136b
line 810why, one step back810#### nodeOptionsRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 811why, one step back811Add `node` option (#804)ehmickybefore adoption663136b
lines 812–813why, one step back812Type: `string[]`\813Default: [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI options)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 814why, one step back814Add `node` option (#804)ehmickybefore adoption663136b
line 815why, one step back815List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#nodepath).Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 816why, one step back816Add `node` option (#804)ehmickybefore adoption663136b
lines 817–820why, one step back817Requires the [`node`](#node) option to be `true`.818819#### nodePath820Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 821why, one step back821Type: `string | URL`\Add `node` option (#804)ehmickybefore adoption663136b
line 822why, one step back822Default: [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 823why, one step back823Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
line 824why, one step back824Path to the Node.js executable.Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 825why, one step back825Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
line 826why, one step back826For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version.Improve interaction of the `preferLocal`, `node` and `nodePath` options (#841)ehmickybefore adoptionb965682
lines 827–828why, one step back827828Requires the [`node`](#node) option to be `true`.Add `node` option (#804)ehmickybefore adoption663136b
line 829why, one step back829Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 830–831why, one step back830#### verbose831Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
lines 832–833why, one step back832Type: `'none' | 'short' | 'full'`\833Default: `'none'`Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 834why, one step back834Print errors with verbose option (#890)ehmickybefore adoption209f78f
line 835why, one step back835If `verbose` is `'short'` or `'full'`, [prints each command](#verbose-mode) on `stderr` before executing it. When the command completes, prints its duration and (if it failed) its error.Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 836why, one step back836Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
lines 837–838why, one step back837If `verbose` is `'full'`, the command's `stdout` and `stderr` are printed too, unless either:838- the [`stdout`](#stdout-1)/[`stderr`](#stderr-1) option is `ignore` or `inherit`.Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 839why, one step back839- the `stdout`/`stderr` is redirected to [a stream](https://nodejs.org/api/stream.html#readablepipedestination-options), [a file](#stdout-1), a file descriptor, or [another subprocess](#pipefile-arguments-options).Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 840why, one step back840- the [`encoding` option](#encoding) is binary.Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
lines 841–842why, one step back841842This can also be set to `'full'` by setting the `NODE_DEBUG=execa` environment variable in the current process.Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 843why, one step back843Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 844–848why, one step back844#### buffer845846Type: `boolean`\847Default: `true`848Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 849why, one step back849Whether to return the subprocess' output using the [`result.stdout`](#stdout), [`result.stderr`](#stderr), [`result.all`](#all-1) and [`result.stdio`](#stdio) properties.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 850why, one step back850Improve `buffer: false` behavior (#747)ehmickybefore adoptiona510995
lines 851–852why, one step back851On failure, the [`error.stdout`](#stdout), [`error.stderr`](#stderr), [`error.all`](#all-1) and [`error.stdio`](#stdio) properties are used instead.852Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 853why, one step back853When `buffer` is `false`, the output can still be read using the [`subprocess.stdout`](#stdout-1), [`subprocess.stderr`](#stderr-1), [`subprocess.stdio`](https://nodejs.org/api/child_process.html#subprocessstdio) and [`subprocess.all`](#all) streams. If the output is read, this should be done right away to avoid missing any data.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 854–858why, one step back854855#### input856857Type: `string | Uint8Array | stream.Readable`858Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 859why, one step back859Write some input to the subprocess' `stdin`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 860–866why, one step back860861See also the [`inputFile`](#inputfile) and [`stdin`](#stdin) options.862863#### inputFile864865Type: `string | URL`866Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 867why, one step back867Use a file as input to the subprocess' `stdin`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 868–872why, one step back868869See also the [`input`](#input) and [`stdin`](#stdin) options.870871#### stdin872Add support for `std*: TransformStream` option (#938)ehmickybefore adoption45824d6
line 873why, one step back873Type: `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)\Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 874why, one step back874Default: `inherit` with [`$`](#file-arguments-options), `pipe` otherwiseRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 875why, one step back875Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 876–877why, one step back876[How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard input. This can be:877- `'pipe'`: Sets [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin) stream.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 878–882why, one step back878- `'overlapped'`: Like `'pipe'` but asynchronous on Windows.879- `'ignore'`: Do not use `stdin`.880- `'inherit'`: Re-use the current process' `stdin`.881- an integer: Re-use a specific file descriptor from the current process.882- a [Node.js `Readable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13
line 883why, one step back883- `{ file: 'path' }` object.Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd
lines 884–886why, one step back884- a file URL.885- a web [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream).886- an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol) or an [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)Allow `stdin: uint8Array` option (#670)ehmickybefore adoption2ac81d4
line 887why, one step back887- an `Uint8Array`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 888–890why, one step back888889This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.890Add support for `std*: TransformStream` option (#938)ehmickybefore adoption45824d6
line 891why, one step back891This can also be a generator function, a [`Duplex`](docs/transform.md#duplextransform-streams) or a web [`TransformStream`](docs/transform.md#duplextransform-streams) to transform the input. [Learn more.](docs/transform.md)Allow passing generators to the `std*` options (#693)ehmickybefore adoptione8f6bbd
line 892why, one step back892Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 893–894why, one step back893#### stdout894Add support for `std*: TransformStream` option (#938)ehmickybefore adoption45824d6
line 895why, one step back895Type: `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)\Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 896–897why, one step back896Default: `pipe`897Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 898–899why, one step back898[How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard output. This can be:899- `'pipe'`: Sets [`subprocessResult.stdout`](#stdout) (as a string or `Uint8Array`) and [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout) (as a stream).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 900–904why, one step back900- `'overlapped'`: Like `'pipe'` but asynchronous on Windows.901- `'ignore'`: Do not use `stdout`.902- `'inherit'`: Re-use the current process' `stdout`.903- an integer: Re-use a specific file descriptor from the current process.904- a [Node.js `Writable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13
line 905why, one step back905- `{ file: 'path' }` object.Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd
lines 906–907why, one step back906- a file URL.907- a web [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 908–910why, one step back908909This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.910Add support for `std*: TransformStream` option (#938)ehmickybefore adoption45824d6
line 911why, one step back911This can also be a generator function, a [`Duplex`](docs/transform.md#duplextransform-streams) or a web [`TransformStream`](docs/transform.md#duplextransform-streams) to transform the output. [Learn more.](docs/transform.md)Allow passing generators to the `std*` options (#693)ehmickybefore adoptione8f6bbd
line 912why, one step back912Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 913–914why, one step back913#### stderr914Add support for `std*: TransformStream` option (#938)ehmickybefore adoption45824d6
line 915why, one step back915Type: `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)\Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 916–917why, one step back916Default: `pipe`917Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 918–919why, one step back918[How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard error. This can be:919- `'pipe'`: Sets [`subprocessResult.stderr`](#stderr) (as a string or `Uint8Array`) and [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr) (as a stream).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 920–924why, one step back920- `'overlapped'`: Like `'pipe'` but asynchronous on Windows.921- `'ignore'`: Do not use `stderr`.922- `'inherit'`: Re-use the current process' `stderr`.923- an integer: Re-use a specific file descriptor from the current process.924- a [Node.js `Writable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13
line 925why, one step back925- `{ file: 'path' }` object.Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd
lines 926–927why, one step back926- a file URL.927- a web [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 928–930why, one step back928929This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.930Add support for `std*: TransformStream` option (#938)ehmickybefore adoption45824d6
line 931why, one step back931This can also be a generator function, a [`Duplex`](docs/transform.md#duplextransform-streams) or a web [`TransformStream`](docs/transform.md#duplextransform-streams) to transform the output. [Learn more.](docs/transform.md)Allow passing generators to the `std*` options (#693)ehmickybefore adoptione8f6bbd
line 932why, one step back932Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 933–934why, one step back933#### stdio934Add support for `std*: TransformStream` option (#938)ehmickybefore adoption45824d6
line 935why, one step back935Type: `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)\Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 936–941why, one step back936Default: `pipe`937938Like the [`stdin`](#stdin), [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options but for all file descriptors at once. For example, `{stdio: ['ignore', 'pipe', 'pipe']}` is the same as `{stdin: 'ignore', stdout: 'pipe', stderr: 'pipe'}`.939940A single string can be used as a shortcut. For example, `{stdio: 'pipe'}` is the same as `{stdin: 'pipe', stdout: 'pipe', stderr: 'pipe'}`.941Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 942why, one step back942The array can have more than 3 items, to create additional file descriptors beyond `stdin`/`stdout`/`stderr`. For example, `{stdio: ['pipe', 'pipe', 'pipe', 'pipe']}` sets a fourth file descriptor.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 943–948why, one step back943944#### all945946Type: `boolean`\947Default: `false`948Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 949why, one step back949Add an `.all` property on the [promise](#all) and the [resolved value](#all-1). The property contains the output of the subprocess with `stdout` and `stderr` [interleaved](#ensuring-all-output-is-interleaved).Line-wise standard streams (#741)ehmickybefore adoption479d12e
lines 950–955why, one step back950951#### lines952953Type: `boolean`\954Default: `false`955Simplify `lines` option (#929)ehmickybefore adoptiond30fcbc
line 956why, one step back956Set [`result.stdout`](#stdout), [`result.stderr`](#stderr), [`result.all`](#all-1) and [`result.stdio`](#stdio) as arrays of strings, splitting the subprocess' output into lines.Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
line 957why, one step back957Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 958why, one step back958This cannot be used if the [`encoding` option](#encoding) is binary.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 959why, one step back959Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 960why, one step back960#### encodingAdd `ipc` option (#794)ehmickybefore adoptionc8a7961
line 961why, one step back961Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 962why, one step back962Type: `string`\Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 963why, one step back963Default: `'utf8'`Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 964why, one step back964Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
lines 965–971why, one step back965If the subprocess outputs text, specifies its character encoding, either `'utf8'` or `'utf16le'`.966967If it outputs binary data instead, this should be either:968- `'buffer'`: returns the binary output as an `Uint8Array`.969- `'hex'`, `'base64'`, `'base64url'`, [`'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.970971The output is available with [`result.stdout`](#stdout), [`result.stderr`](#stderr) and [`result.stdio`](#stdio).Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 972why, one step back972Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 973–979why, one step back973#### stripFinalNewline974975Type: `boolean`\976Default: `true`977978Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.979Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 980–981why, one step back980If the [`lines` option](#lines) is true, this applies to each output line instead.981Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 982why, one step back982#### maxBufferRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 983why, one step back983Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 984why, one step back984Type: `number`\Improve documentation of `maxBuffer` (#921)ehmickybefore adoptionbedb729
line 985why, one step back985Default: `100_000_000`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 986why, one step back986Improve documentation of `maxBuffer` (#921)ehmickybefore adoptionbedb729
lines 987–993why, one step back987Largest amount of data allowed on [`stdout`](#stdout), [`stderr`](#stderr) and [`stdio`](#stdio).988989This is measured:990- By default: in [characters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length).991- If the [`encoding` option](#encoding) is `'buffer'`: in bytes.992- If the [`lines` option](#lines) is `true`: in lines.993- If a [transform in object mode](docs/transform.md#object-mode) is used: in objects.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 994why, one step back994Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 995why, one step back995#### ipcRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 996why, one step back996Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 997why, one step back997Type: `boolean`\Add `node` option (#804)ehmickybefore adoption663136b
line 998why, one step back998Default: `true` if the [`node`](#node) option is enabled, `false` otherwiseRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 999why, one step back999Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1000why, one step back1000Enables exchanging messages with the subprocess using [`subprocess.send(value)`](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback) and [`subprocess.on('message', (value) => {})`](https://nodejs.org/api/child_process.html#event-message).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1001–1004why, one step back10011002#### serialization10031004Type: `string`\Change default value of `serialization` option to `advanced` (#905)ehmickybefore adoption4577582
line 1005why, one step back1005Default: `'advanced'`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1006why, one step back1006Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1007why, one step back1007Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#ipc) option:Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1008–1014why, one step back1008 - `json`: Uses `JSON.stringify()` and `JSON.parse()`.1009 - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)10101011[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)10121013#### detached1014Fix incorrect Markdown indentation in `readme.md` (#802)ehmickybefore adoption3bd96ba
lines 1015–1016why, one step back1015Type: `boolean`\1016Default: `false`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1017why, one step back1017Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1018why, one step back1018Prepare subprocess to run independently of the current process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1019why, one step back1019Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1020why, one step back1020#### cleanupRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1021why, one step back1021Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 1022–1023why, one step back1022Type: `boolean`\1023Default: `true`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1024why, one step back1024Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 1025–1027why, one step back1025Kill the subprocess when the current process exits unless either:1026 - the subprocess is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)1027 - the current process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exitRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1028–1033why, one step back10281029#### timeout10301031Type: `number`\1032Default: `0`1033Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1034why, one step back1034If `timeout` is greater than `0`, the subprocess will be [terminated](#killsignal) if it runs for longer than that amount of milliseconds.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1035why, one step back1035Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf
line 1036why, one step back1036#### cancelSignalRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1037why, one step back1037Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1038why, one step back1038Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1039why, one step back1039Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1040why, one step back1040You can abort the subprocess using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1041why, one step back1041Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1042why, one step back1042When `AbortController.abort()` is called, [`.isCanceled`](#iscanceled) becomes `true`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1043why, one step back1043Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34
line 1044why, one step back1044#### forceKillAfterDelayImprove graceful exit (#714)ehmickybefore adoption5eeaab5
lines 1045–1048why, one step back10451046Type: `number | false`\1047Default: `5000`1048Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1049why, one step back1049If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).Improve graceful exit (#714)ehmickybefore adoption5eeaab5
lines 1050–1052why, one step back10501051The grace period is 5 seconds by default. This feature can be disabled with `false`.1052Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1053why, one step back1053This works when the subprocess is terminated by either:Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf
line 1054why, one step back1054- the [`cancelSignal`](#cancelsignal), [`timeout`](#timeout), [`maxBuffer`](#maxbuffer) or [`cleanup`](#cleanup) optionImprove graceful exit (#714)ehmickybefore adoption5eeaab5
lines 1055–1056why, one step back1055- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with no arguments1056Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1057why, one step back1057This does not work when the subprocess is terminated by either:Improve graceful exit (#714)ehmickybefore adoption5eeaab5
lines 1058–1061why, one step back1058- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with an argument1059- calling [`process.kill(subprocess.pid)`](https://nodejs.org/api/process.html#processkillpid-signal)1060- sending a termination signal from another process1061Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1062why, one step back1062Also, this does not work on Windows, because Windows [doesn't support signals](https://nodejs.org/api/process.html#process_signal_events): `SIGKILL` and `SIGTERM` both terminate the subprocess immediately. Other packages (such as [`taskkill`](https://github.com/sindresorhus/taskkill)) can be used to achieve fail-safe termination on Windows.Improve graceful exit (#714)ehmickybefore adoption5eeaab5
line 1063why, one step back1063Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1064why, one step back1064#### killSignalRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1065why, one step back1065Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 1066–1067why, one step back1066Type: `string | number`\1067Default: `SIGTERM`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1068why, one step back1068Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1069why, one step back1069Signal used to terminate the subprocess when:Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf
line 1070why, one step back1070- using the [`cancelSignal`](#cancelsignal), [`timeout`](#timeout), [`maxBuffer`](#maxbuffer) or [`cleanup`](#cleanup) optionRe-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1071why, one step back1071- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with no argumentsRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1072why, one step back1072Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1073why, one step back1073This can be either a name (like `"SIGTERM"`) or a number (like `9`).Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1074why, one step back1074Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1075why, one step back1075#### argv0Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1076why, one step back1076Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1077why, one step back1077Type: `string`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1078why, one step back1078Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1079why, one step back1079Explicitly set the value of `argv[0]` sent to the subprocess. This will be set to `file` if not specified.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1080why, one step back1080Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1081why, one step back1081#### uidRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1082why, one step back1082Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1083why, one step back1083Type: `number`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1084why, one step back1084Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1085why, one step back1085Sets the user identity of the subprocess.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1086why, one step back1086Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1087why, one step back1087#### gidRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1088why, one step back1088Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1089why, one step back1089Type: `number`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1090why, one step back1090Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1091why, one step back1091Sets the group identity of the subprocess.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1092why, one step back1092Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1093why, one step back1093#### windowsVerbatimArgumentsRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1094why, one step back1094Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 1095–1096why, one step back1095Type: `boolean`\1096Default: `false`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1097why, one step back1097Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1098why, one step back1098If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1099why, one step back1099Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1100why, one step back1100#### windowsHideRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1101why, one step back1101Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 1102–1103why, one step back1102Type: `boolean`\1103Default: `true`Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
line 1104why, one step back1104Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1105why, one step back1105On Windows, do not create a new console window. Please note this also prevents `CTRL-C` [from working](https://github.com/nodejs/node/issues/29837) on Windows.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1106–1114why, one step back11061107## Tips11081109### Redirect stdin/stdout/stderr to multiple destinations11101111The [`stdin`](#stdin), [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options can be an array of values.1112The following example redirects `stdout` to both the terminal and an `output.txt` file, while also retrieving its value programmatically.11131114```jsAllow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf
line 1115why, one step back1115const {stdout} = await execa('npm', ['install'], {stdout: ['inherit', './output.txt', 'pipe']});Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1116–1118why, one step back1116console.log(stdout);1117```1118Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1119why, one step back1119When combining `inherit` with other values, please note that the subprocess will not be an interactive TTY, even if the current process is one.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1120–1133why, one step back11201121### Redirect a Node.js stream from/to stdin/stdout/stderr11221123When passing a Node.js stream to the [`stdin`](#stdin), [`stdout`](#stdout-1) or [`stderr`](#stderr-1) option, Node.js requires that stream to have an underlying file or socket, such as the streams created by the `fs`, `net` or `http` core modules. Otherwise the following error is thrown.11241125```1126TypeError [ERR_INVALID_ARG_VALUE]: The argument 'stdio' is invalid.1127```11281129This limitation can be worked around by passing either:1130 - a web stream ([`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) or [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream))1131 - `[nodeStream, 'pipe']` instead of `nodeStream`11321133```diffAllow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf
lines 1134–1135why, one step back1134- await execa(..., {stdout: nodeStream});1135+ await execa(..., {stdout: [nodeStream, 'pipe']});Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1136–1139why, one step back1136```11371138### Retry on error1139Improve graceful exit (#714)ehmickybefore adoption5eeaab5
line 1140why, one step back1140Safely handle failures by using automatic retries and exponential backoff with the [`p-retry`](https://github.com/sindresorhus/p-retry) package:Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1141–1152why, one step back11411142```js1143import pRetry from 'p-retry';11441145const run = async () => {1146 const results = await execa('curl', ['-sSL', 'https://sindresorhus.com/unicorn']);1147 return results;1148};11491150console.log(await pRetry(run, {retries: 5}));1151```1152Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1153why, one step back1153### Cancelling a subprocessRefactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1154–1158why, one step back11541155```js1156import {execa} from 'execa';11571158const abortController = new AbortController();Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf
line 1159why, one step back1159const subprocess = execa('node', [], {cancelSignal: abortController.signal});Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1160–1187why, one step back11601161setTimeout(() => {1162 abortController.abort();1163}, 1000);11641165try {1166 await subprocess;1167} catch (error) {1168 console.log(error.isTerminated); // true1169 console.log(error.isCanceled); // true1170}1171```11721173### Execute the current package's binary11741175Execa can be combined with [`get-bin-path`](https://github.com/ehmicky/get-bin-path) to test the current package's binary. As opposed to hard-coding the path to the binary, this validates that the `package.json` `bin` field is correctly set up.11761177```js1178import {getBinPath} from 'get-bin-path';11791180const binPath = await getBinPath();1181await execa(binPath);1182```11831184### Ensuring `all` output is interleaved11851186The `all` [stream](#all) and [string/`Uint8Array`](#all-1) properties are guaranteed to interleave [`stdout`](#stdout) and [`stderr`](#stderr).1187Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1188why, one step back1188However, for performance reasons, the subprocess might buffer and merge multiple simultaneous writes to `stdout` or `stderr`. This prevents proper interleaving.Refactor duplicate code between `execa()` and `execaSync()` (#648)ehmickybefore adoption4fb84f0
lines 1189–1225why, one step back11891190For example, this prints `1 3 2` instead of `1 2 3` because both `console.log()` are merged into a single write.11911192```js1193import {execa} from 'execa';11941195const {all} = await execa('node', ['example.js'], {all: true});1196console.log(all);1197```11981199```js1200// example.js1201console.log('1'); // writes to stdout1202console.error('2'); // writes to stderr1203console.log('3'); // writes to stdout1204```12051206This can be worked around by using `setTimeout()`.12071208```js1209import {setTimeout} from 'timers/promises';12101211console.log('1');1212console.error('2');1213await setTimeout(0);1214console.log('3');1215```12161217## Related12181219- [gulp-execa](https://github.com/ehmicky/gulp-execa) - Gulp plugin for Execa1220- [nvexeca](https://github.com/ehmicky/nvexeca) - Run Execa using any Node.js version12211222## Maintainers12231224- [Sindre Sorhus](https://github.com/sindresorhus)1225- [@ehmicky](https://github.com/ehmicky)