readme.md
This file
Path
readme.md
1,216 lines · 47.1 KiB · Markdown
Last changed by
Simplify `lines` option (#929)ehmickybefore adoptiond30fcbc
History of this fileTake it
The walk stopped after 200 commits: lines older than 640ae39 point at it.
Fix `stdio` option (#634)ehmickybefore adoption640ae39
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>Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 39–53why, one step back39 </p>40</div>4142---4344<br>4546## Why4748This package improves [`child_process`](https://nodejs.org/api/child_process.html) methods with:4950- [Promise interface](#execacommandcommand-options).51- [Scripts interface](#scripts-interface), like `zx`.52- 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).Fix `stdio` option (#634)ehmickybefore adoption640ae39
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).Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 62–117why, one step back62- Can specify file and arguments [as a single string](#execacommandcommand-options) without a shell.63- [Verbose mode](#verbose-mode) for debugging.64- More descriptive errors.65- Higher max buffer: 100 MB instead of 1 MB.6667## Install6869```sh70npm install execa71```7273## Usage7475### Promise interface7677```js78import {execa} from 'execa';7980const {stdout} = await execa('echo', ['unicorns']);81console.log(stdout);82//=> 'unicorns'83```8485### Scripts interface8687For more information about Execa scripts, please see [this page](docs/scripts.md).8889#### Basic9091```js92import {$} from 'execa';9394const branch = await $`git branch --show-current`;95await $`dep deploy --branch=${branch}`;96```9798#### Multiple arguments99100```js101import {$} from 'execa';102103const args = ['unicorns', '&', 'rainbows!'];104const {stdout} = await $`echo ${args}`;105console.log(stdout);106//=> 'unicorns & rainbows!'107```108109#### With options110111```js112import {$} from 'execa';113114await $({stdio: 'inherit'})`echo unicorns`;115//=> 'unicorns'116```117Improve documentation of global script options (#870)ehmickybefore adoption146fa07
line 118why, one step back118#### Global/shared optionsFix `stdio` option (#634)ehmickybefore adoption640ae39
lines 119–120why, one step back119120```jsImprove documentation of global script options (#870)ehmickybefore adoption146fa07
line 121why, one step back121import {$ as $_} from 'execa';Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 122why, one step back122Improve documentation of global script options (#870)ehmickybefore adoption146fa07
line 123why, one step back123const $ = $_({stdio: 'inherit'});Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 124why, one step back124Improve documentation of global script options (#870)ehmickybefore adoption146fa07
line 125why, one step back125await $`echo unicorns`;Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 126–127why, one step back126//=> 'unicorns'127Improve documentation of global script options (#870)ehmickybefore adoption146fa07
line 128why, one step back128await $`echo rainbows`;Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 129–131why, one step back129//=> 'rainbows'130```131`.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562
lines 132–141why, one step back132#### Piping133134```js135import {$} from 'execa';136137await $`npm run build`138 .pipe`sort`139 .pipe`head -n2`;140```141Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 142–149why, one step back142#### Verbose mode143144```sh145> node file.js146unicorns147rainbows148149> NODE_DEBUG=execa node file.jsPrint output with `verbose` option (#884)ehmickybefore adoption6fda30f
line 150why, one step back150[19:49:00.360] [0] $ echo unicornsFix `stdio` option (#634)ehmickybefore adoption640ae39
line 151why, one step back151unicornsPrint process completion with verbose option (#887)ehmickybefore adoption7264bcf
line 152why, one step back152[19:49:00.383] [0] √ (done in 23ms)Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
line 153why, one step back153[19:49:00.383] [1] $ echo rainbowsFix `stdio` option (#634)ehmickybefore adoption640ae39
line 154why, one step back154rainbowsPrint process completion with verbose option (#887)ehmickybefore adoption7264bcf
line 155why, one step back155[19:49:00.404] [1] √ (done in 21ms)Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 156–165why, one step back156```157158### Input/output159160#### Redirect output to a file161162```js163import {execa} from 'execa';164165// Similar to `echo unicorns > stdout.txt` in BashOnly allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305
line 166why, one step back166await execa('echo', ['unicorns'], {stdout: {file: 'stdout.txt'}});Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 167–168why, one step back167168// Similar to `echo unicorns 2> stdout.txt` in BashOnly allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305
line 169why, one step back169await execa('echo', ['unicorns'], {stderr: {file: 'stderr.txt'}});Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 170–171why, one step back170171// Similar to `echo unicorns &> stdout.txt` in BashOnly allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305
line 172why, one step back172await execa('echo', ['unicorns'], {stdout: {file: 'all.txt'}, stderr: {file: 'all.txt'}});Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 173–185why, one step back173```174175#### Redirect input from a file176177```js178import {execa} from 'execa';179180// Similar to `cat < stdin.txt` in Bash181const {stdout} = await execa('cat', {inputFile: 'stdin.txt'});182console.log(stdout);183//=> 'unicorns'184```185Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 186why, one step back186#### Save and pipe output from a subprocessFix `stdio` option (#634)ehmickybefore adoption640ae39
lines 187–190why, one step back187188```js189import {execa} from 'execa';190Only allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305
line 191why, one step back191const {stdout} = await execa('echo', ['unicorns'], {stdout: ['pipe', 'inherit']});Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 192–196why, one step back192// Prints `unicorns`193console.log(stdout);194// Also returns 'unicorns'195```196Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 197why, one step back197#### Pipe multiple subprocessesFix `stdio` option (#634)ehmickybefore adoption640ae39
lines 198–201why, one step back198199```js200import {execa} from 'execa';201Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 202–203why, one step back202// Similar to `npm run build | sort | head -n2` in Bash203const {stdout, pipedFrom} = await execa('npm', ['run', 'build'])Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 204–205why, one step back204 .pipe('sort')205 .pipe('head', ['-n2']);Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 206–208why, one step back206console.log(stdout); // Result of `head -n2`207console.log(pipedFrom[0]); // Result of `sort`208console.log(pipedFrom[0].pipedFrom[0]); // Result of `npm run build`Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 209–210why, one step back209```210Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
lines 211–222why, one step back211#### Iterate over output lines212213```js214import {execa} from 'execa';215216for await (const line of execa('npm', ['run', 'build'])) {217 if (line.includes('ERROR')) {218 console.log(line);219 }220}221```222Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 223–233why, one step back223### Handling Errors224225```js226import {execa} from 'execa';227228// Catching an error229try {230 await execa('unknown', ['command']);231} catch (error) {232 console.log(error);233 /*Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 234–237why, one step back234 ExecaError: Command failed with ENOENT: unknown command235 spawn unknown ENOENT236 at ...237 at ... {Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 238why, one step back238 shortMessage: 'Command failed with ENOENT: unknown command\nspawn unknown ENOENT',Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 239–241why, one step back239 originalMessage: 'spawn unknown ENOENT',240 command: 'unknown command',241 escapedCommand: 'unknown command',Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
lines 242–243why, one step back242 cwd: '/path/to/cwd',243 durationMs: 28.217566,Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 244–246why, one step back244 failed: true,245 timedOut: false,246 isCanceled: false,Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 247why, one step back247 isTerminated: false,Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 248why, one step back248 code: 'ENOENT',Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
lines 249–252why, one step back249 stdout: '',250 stderr: '',251 stdio: [undefined, '', ''],252 pipedFrom: []Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 253–261why, one step back253 [cause]: Error: spawn unknown ENOENT254 at ...255 at ... {256 errno: -2,257 code: 'ENOENT',258 syscall: 'spawn unknown',259 path: 'unknown',260 spawnargs: [ 'command' ]261 }Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 262–272why, one step back262 }263 */264}265```266267## API268269### Methods270271#### execa(file, arguments?, options?)272Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 273–275why, one step back273`file`: `string | URL`\274`arguments`: `string[]`\275`options`: [`Options`](#options-1)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 276why, one step back276_Returns_: [`Subprocess`](#subprocess)Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 277why, one step back277Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 278–279why, one step back278Executes a command using `file ...arguments`.279Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 280–284why, one step back280Arguments are [automatically escaped](#shell-syntax). They can contain any character, including spaces.281282This is the preferred method when executing single commands.283284#### $\`command\`Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 285why, one step back285#### $(options)\`command\`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 286why, one step back286Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 287–288why, one step back287`command`: `string`\288`options`: [`Options`](#options-1)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 289why, one step back289_Returns_: [`Subprocess`](#subprocess)Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 290why, one step back290Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 291why, one step back291Executes a command. The `command` string includes both the `file` and its `arguments`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 292why, one step back292Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 293–294why, one step back293Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces, tabs and newlines must use `${}` like `` $`echo ${'has space'}` ``.294Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 295–296why, one step back295This is the preferred method when executing multiple commands in a script file.296Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 297why, one step back297The `command` string can inject any `${value}` with the following types: string, number, [`subprocess`](#subprocess) or an array of those types. For example: `` $`echo one ${'two'} ${3} ${['four', 'five']}` ``. For `${subprocess}`, the subprocess's `stdout` is used.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 298why, one step back298Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 299–300why, one step back299The `command` string can use [multiple lines and indentation](docs/scripts.md#multiline-commands).300Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 301–304why, one step back301For more information, please see [this section](#scripts-interface) and [this page](docs/scripts.md).302303#### $(options)304Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 305–306why, one step back305`options`: [`Options`](#options-1)\306_Returns_: [`$`](#command)Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 307why, one step back307Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 308–309why, one step back308Returns a new instance of [`$`](#command) but with different default [`options`](#options-1). Consecutive calls are merged to previous ones.309Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 310–315why, one step back310This can be used to either:311- Set options for a specific command: `` $(options)`command` ``312- Share options for multiple commands: `` const $$ = $(options); $$`command`; $$`otherCommand`; ``313314#### execaCommand(command, options?)315Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 316–317why, one step back316`command`: `string`\317`options`: [`Options`](#options-1)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 318why, one step back318_Returns_: [`Subprocess`](#subprocess)Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 319why, one step back319Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 320–321why, one step back320Executes a command. The `command` string includes both the `file` and its `arguments`.321Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 322–325why, one step back322Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces must be escaped with a backslash like `execaCommand('echo has\\ space')`.323324This is the preferred method when executing a user-supplied `command` string, such as in a REPL.325Add `node` option (#804)ehmickybefore adoption663136b
lines 326–327why, one step back326#### execaNode(scriptPath, arguments?, options?)327Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 328–330why, one step back328`file`: `string | URL`\329`arguments`: `string[]`\330`options`: [`Options`](#options-1)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 331why, one step back331_Returns_: [`Subprocess`](#subprocess)Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 332why, one step back332Add `node` option (#804)ehmickybefore adoption663136b
lines 333–336why, one step back333Same as [`execa()`](#execacommandcommand-options) but using the [`node`](#node) option.334335Executes a Node.js file using `node scriptPath ...arguments`.336Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 337why, one step back337This is the preferred method when executing Node.js files.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 338why, one step back338Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 339–340why, one step back339#### execaSync(file, arguments?, options?)340#### execaCommandSync(command, options?)Fix incorrect Markdown indentation in `readme.md` (#802)ehmickybefore adoption3bd96ba
lines 341–342why, one step back341#### $.sync\`command\`342#### $.s\`command\`Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
lines 343–344why, one step back343#### $.sync(options)\`command\`344#### $.s(options)\`command\`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 345why, one step back345Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61
line 346why, one step back346Same as [`execa()`](#execacommandcommand-options), [`execaCommand()`](#execacommand-command-options), [$\`command\`](#command) but synchronous.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 347why, one step back347Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
line 348why, one step back348Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`cancelSignal`](#cancelsignal), [`lines`](#lines) and [`verbose: 'full'`](#verbose). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable, a [transform](docs/transform.md) or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd
line 349why, one step back349Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 350why, one step back350Returns 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) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 351–355why, one step back351352### Shell syntax353354For 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.355Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 356why, one step back356### subprocessFix `stdio` option (#634)ehmickybefore adoption640ae39
lines 357–358why, one step back357358The return value of all [asynchronous methods](#methods) is both:Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 359why, one step back359- a `Promise` resolving or rejecting with a [`subprocessResult`](#subprocessResult).Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 360–365why, one step back360- a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following additional methods and properties.361362#### all363364Type: `ReadableStream | undefined`365Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0
line 366why, one step back366Stream [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).Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 367–369why, one step back367368This is `undefined` if either:369- the [`all` option](#all-2) is `false` (the default value)Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 370why, one step back370- 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)Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 371why, one step back371Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 372why, one step back372#### pipe(file, arguments?, options?)Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 373why, one step back373Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 374–376why, one step back374`file`: `string | URL`\375`arguments`: `string[]`\376`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 377why, one step back377_Returns_: [`Promise<SubprocessResult>`](#subprocessresult)Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 378why, one step back378Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 379why, one step back379[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.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 380why, one step back380Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 381–382why, one step back381This follows the same syntax as [`execa(file, arguments?, options?)`](#execafile-arguments-options) except both [regular options](#options-1) and [pipe-specific options](#pipeoptions) can be specified.382Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 383why, one step back383This can be called multiple times to chain a series of subprocesses.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 384why, one step back384Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 385why, one step back385Multiple 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 386why, one step back386Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 387why, one step back387This is usually the preferred method to pipe subprocesses.Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 388why, one step back388Fix Markdown typo (#869)ehmickybefore adoptionc8ba426
lines 389–390why, one step back389#### pipe\`command\`390#### pipe(options)\`command\``.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562
line 391why, one step back391Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 392–393why, one step back392`command`: `string`\393`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 394why, one step back394_Returns_: [`Promise<SubprocessResult>`](#subprocessresult)`.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562
line 395why, one step back395Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 396why, one step back396Like [`.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 [`$`](#command).Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 397why, one step back397Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 398why, one step back398This is the preferred method to pipe subprocesses when using [`$`](#command).Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 399why, one step back399Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 400why, one step back400#### pipe(secondSubprocess, pipeOptions?)Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 401why, one step back401Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 402why, one step back402`secondSubprocess`: [`execa()` return value](#subprocess)\Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 403why, one step back403`pipeOptions`: [`PipeOptions`](#pipeoptions)\Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 404why, one step back404_Returns_: [`Promise<SubprocessResult>`](#subprocessresult)Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 405why, one step back405Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 406why, one step back406Like [`.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 407why, one step back407Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 408why, one step back408This 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 409why, one step back409Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 410why, one step back410##### pipeOptionsOnly allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305
line 411why, one step back411Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 412–415why, one step back412Type: `object`413414##### pipeOptions.from415Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 416why, one step back416Type: `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 417–418why, one step back417Default: `"stdout"`418Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 419why, one step back419Which stream to pipe from the source subprocess. A file descriptor like `"fd3"` can also be passed.Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 420–421why, one step back420421`"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 422–424why, one step back422423##### pipeOptions.to424Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 425why, one step back425Type: `"stdin" | "fd3" | "fd4" | ...`\Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2
lines 426–427why, one step back426Default: `"stdin"`427Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 428why, one step back428Which stream to pipe to the destination subprocess. A file descriptor like `"fd3"` can also be passed.Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 429why, one step back429Rename `signal` option to `unpipeSignal` (#852)ehmickybefore adoption9dc1141
line 430why, one step back430##### pipeOptions.unpipeSignalImprove piping processes (#834)ehmickybefore adoption1a47ea2
lines 431–433why, one step back431432Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)433Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 434why, one step back434Unpipe the subprocess when the signal aborts.Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 435why, one step back435Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 436why, one step back436The [`.pipe()`](#pipefile-arguments-options) method will be rejected with a cancellation error.Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 437why, one step back437Add `.kill(signal, error)` (#836)ehmickybefore adoption30a662d
lines 438–439why, one step back438#### kill(signal, error?)439#### kill(error?)Add `.kill(error)` (#811)ehmickybefore adoption9cbb817
line 440why, one step back440Add `.kill(signal, error)` (#836)ehmickybefore adoption30a662d
lines 441–442why, one step back441`signal`: `string | number`\442`error`: `Error`\Add `.kill(error)` (#811)ehmickybefore adoption9cbb817
lines 443–444why, one step back443_Returns_: `boolean`444Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 445why, one step back445Sends 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 446why, one step back446Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 447why, one step back447This returns `false` when the signal could not be sent, for example when the subprocess has already exited.Add `.kill(error)` (#811)ehmickybefore adoption9cbb817
line 448why, one step back448Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 449why, one step back449When 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 450–452why, one step back450451[More info.](https://nodejs.org/api/child_process.html#subprocesskillsignal)452Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
lines 453–467why, one step back453#### [Symbol.asyncIterator]()454455_Returns_: `AsyncIterable`456457Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.458459The 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).460461#### iterable(readableOptions?)462463`readableOptions`: [`ReadableOptions`](#readableoptions)\464_Returns_: `AsyncIterable`465466Same as [`subprocess[Symbol.asyncIterator]`](#symbolasynciterator) except [options](#readableoptions) can be provided.467Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 468why, one step back468#### readable(readableOptions?)Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 469why, one step back469Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 470why, one step back470`readableOptions`: [`ReadableOptions`](#readableoptions)\Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 471–476why, one step back471_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream472473Converts the subprocess to a readable stream.474475Unlike [`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.476Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 477why, one step back477Before 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 478why, one step back478Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 479why, one step back479#### writable(writableOptions?)Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 480why, one step back480Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 481why, one step back481`writableOptions`: [`WritableOptions`](#writableoptions)\Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 482–487why, one step back482_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream483484Converts the subprocess to a writable stream.485486Unlike [`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.487Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 488why, one step back488Before 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 489why, one step back489Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 490why, one step back490#### duplex(duplexOptions?)Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 491why, one step back491Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 492why, one step back492`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 493–498why, one step back493_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream494495Converts the subprocess to a duplex stream.496497The 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.498Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 499why, one step back499Before 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 500why, one step back500Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 501why, one step back501##### readableOptionsAdd `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 502–504why, one step back502503Type: `object`504Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 505why, one step back505##### readableOptions.fromAdd `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 506why, one step back506Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 507why, one step back507Type: `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 508–509why, one step back508Default: `"stdout"`509Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 510why, one step back510Which 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 511–513why, one step back511512`"all"` reads both `stdout` and `stderr`. This requires the [`all` option](#all-2) to be `true`.513Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 514why, one step back514##### readableOptions.binaryAdd `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 515why, one step back515Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
lines 516–517why, one step back516Type: `boolean`\517Default: `false` with [`.iterable()`](#iterablereadableoptions), `true` with [`.readable()`](#readablereadableoptions)/[`.duplex()`](#duplexduplexoptions)Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
line 518why, one step back518Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
lines 519–520why, one step back519If `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).520Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 521why, one step back521If `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 522why, one step back522Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 523why, one step back523This is always `true` when the [`encoding` option](#encoding) is binary.Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 524why, one step back524Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
lines 525–527why, one step back525##### readableOptions.preserveNewlines526527Type: `boolean`\Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 528why, one step back528Default: `false` with [`.iterable()`](#iterablereadableoptions), `true` with [`.readable()`](#readablereadableoptions)/[`.duplex()`](#duplexduplexoptions)Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
lines 529–537why, one step back529530If both this option and the [`binary` option](#readableoptionsbinary) is `false`, newlines are stripped from each line.531532##### writableOptions533534Type: `object`535536##### writableOptions.to537Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 538why, one step back538Type: `"stdin" | "fd3" | "fd4" | ...`\Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9
lines 539–540why, one step back539Default: `"stdin"`540Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91
line 541why, one step back541Which 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 542why, one step back542Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 543why, one step back543### SubprocessResultFix `stdio` option (#634)ehmickybefore adoption640ae39
lines 544–546why, one step back544545Type: `object`546Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 547why, one step back547Result of a subprocess execution.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 548why, one step back548Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 549why, one step back549When the subprocess [fails](#failed), it is rejected with an [`ExecaError`](#execaerror) instead.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 550–556why, one step back550551#### command552553Type: `string`554555The file and arguments that were run, for logging purposes.556Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 557why, one step back557This is not escaped and should not be executed directly as a subprocess, including using [`execa()`](#execafile-arguments-options) or [`execaCommand()`](#execacommandcommand-options).Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 558–564why, one step back558559#### escapedCommand560561Type: `string`562563Same as [`command`](#command-1) but escaped.564Better escaping of `result.escapedCommand` (#875)ehmickybefore adoption7b044bb
lines 565–567why, one step back565Unlike `command`, control characters are escaped, which makes it safe to print in a terminal.566567This can also be copied and pasted into a shell, for debugging purposes.Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 568why, one step back568Since the escaping is fairly basic, this should not be executed directly as a subprocess, including using [`execa()`](#execafile-arguments-options) or [`execaCommand()`](#execacommandcommand-options).Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 569why, one step back569Re-order return value properties (#801)ehmickybefore adoption72836f3
line 570why, one step back570#### cwdFix `stdio` option (#634)ehmickybefore adoption640ae39
line 571why, one step back571Re-order return value properties (#801)ehmickybefore adoption72836f3
line 572why, one step back572Type: `string`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 573why, one step back573Improve `cwd` option (#803)ehmickybefore adoption2fd9351
line 574why, one step back574The [current directory](#cwd-1) in which the command was run.Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
lines 575–579why, one step back575576#### durationMs577578Type: `number`579Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 580why, one step back580Duration of the subprocess, in milliseconds.Document and type `exitCode` being `undefined` (#680)ehmickybefore adoption95e5754
line 581why, one step back581Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 582–583why, one step back582#### stdout583Line-wise standard streams (#741)ehmickybefore adoption479d12e
line 584why, one step back584Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 585why, one step back585Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 586why, one step back586The output of the subprocess on `stdout`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 587why, one step back587Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 588why, one step back588This 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).Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 589–591why, one step back589590#### stderr591Line-wise standard streams (#741)ehmickybefore adoption479d12e
line 592why, one step back592Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 593why, one step back593Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 594why, one step back594The output of the subprocess on `stderr`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 595why, one step back595Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 596why, one step back596This 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).Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 597–599why, one step back597598#### all599Line-wise standard streams (#741)ehmickybefore adoption479d12e
line 600why, one step back600Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 601why, one step back601Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 602why, one step back602The output of the subprocess with `stdout` and `stderr` [interleaved](#ensuring-all-output-is-interleaved).Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 603–605why, one step back603604This is `undefined` if either:605- the [`all` option](#all-2) is `false` (the default value)Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 606why, one step back606- 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)Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 607why, one step back607Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 608why, one step back608This 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 609why, one step back609Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
lines 610–611why, one step back610#### stdio611Line-wise standard streams (#741)ehmickybefore adoption479d12e
line 612why, one step back612Type: `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
line 613why, one step back613Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 614why, one step back614The 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 615why, one step back615Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 616why, one step back616Items 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 617why, one step back617Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 618–621why, one step back618#### failed619620Type: `boolean`621Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 622why, one step back622Whether the subprocess failed to run.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 623–627why, one step back623624#### timedOut625626Type: `boolean`627Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 628why, one step back628Whether the subprocess timed out.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 629–633why, one step back629630#### isCanceled631632Type: `boolean`633Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 634why, one step back634Whether the subprocess was canceled using the [`cancelSignal`](#cancelsignal) option.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 635–639why, one step back635636#### isTerminated637638Type: `boolean`639Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 640why, one step back640Whether the subprocess was terminated by a signal (like `SIGTERM`) sent by either:Improve process termination (#724)ehmickybefore adoption1c48d37
lines 641–642why, one step back641- The current process.642- Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 643why, one step back643Re-order return value properties (#801)ehmickybefore adoption72836f3
lines 644–647why, one step back644#### exitCode645646Type: `number | undefined`647Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 648why, one step back648The numeric exit code of the subprocess that was run.Re-order return value properties (#801)ehmickybefore adoption72836f3
line 649why, one step back649Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 650why, one step back650This 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 651why, one step back651Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 652–655why, one step back652#### signal653654Type: `string | undefined`655Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 656why, one step back656The name of the signal (like `SIGTERM`) that terminated the subprocess, sent by either:Improve process termination (#724)ehmickybefore adoption1c48d37
lines 657–658why, one step back657- The current process.658- Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 659why, one step back659Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 660why, one step back660If a signal terminated the subprocess, this property is defined and included in the error message. Otherwise it is `undefined`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 661–665why, one step back661662#### signalDescription663664Type: `string | undefined`665Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 666why, one step back666A human-friendly description of the signal that was used to terminate the subprocess. For example, `Floating point arithmetic error`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 667why, one step back667Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 668why, one step back668If 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 669–671why, one step back669670#### pipedFrom671Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 672why, one step back672Type: [`Array<SubprocessResult | ExecaError>`](#subprocessresult)Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 673why, one step back673Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 674why, one step back674Results 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 675why, one step back675Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 676why, one step back676This array is initially empty and is populated each time the [`.pipe()`](#pipefile-arguments-options) method resolves.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 677why, one step back677Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 678–727why, one step back678### ExecaError679### ExecaSyncError680681Type: `Error`682683Exception thrown when the subprocess [fails](#failed), either:684- its [exit code](#exitcode) is not `0`685- it was [terminated](#isterminated) with a [signal](#signal), including [`.kill()`](#killerror)686- [timing out](#timedout)687- [being canceled](#iscanceled)688- there's not enough memory or there are already too many subprocesses689690This has the same shape as [successful results](#subprocessresult), with the following additional properties.691692#### message693694Type: `string`695696Error 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.697698The subprocess [`stderr`](#stderr), [`stdout`](#stdout) and other [file descriptors' output](#stdio) are appended to the end, separated with newlines and not interleaved.699700#### shortMessage701702Type: `string`703704This is the same as the [`message` property](#message) except it does not include the subprocess [`stdout`](#stdout)/[`stderr`](#stderr)/[`stdio`](#stdio).705706#### originalMessage707708Type: `string | undefined`709710Original 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.711712This exists only if the subprocess exited due to an `error` event or a timeout.713714#### cause715716Type: `unknown | undefined`717718Underlying error, if there is one. For example, this is set by [`.kill(error)`](#killerror).719720This is usually an `Error` instance.721722#### code723724Type: `string | undefined`725726Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.727Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 728–731why, one step back728### options729730Type: `object`731Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 732why, one step back732This 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).Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 733why, one step back733Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 734–735why, one step back734#### reject735Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 736–738why, one step back736Type: `boolean`\737Default: `true`738Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 739why, one step back739Setting this to `false` resolves the promise with the [error](#execaerror) instead of rejecting it.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 740why, one step back740Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 741–757why, one step back741#### shell742743Type: `boolean | string | URL`\744Default: `false`745746If `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.747748We recommend against using this option since it is:749- not cross-platform, encouraging shell-specific syntax.750- slower, because of the additional shell interpretation.751- unsafe, potentially allowing command injection.752753#### cwd754755Type: `string | URL`\756Default: `process.cwd()`757Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 758why, one step back758Current working directory of the subprocess.Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 759why, one step back759Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
line 760why, one step back760This is also used to resolve the [`nodePath`](#nodepath) option when it is a relative path.Improve `cwd` option (#803)ehmickybefore adoption2fd9351
line 761why, one step back761Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 762–768why, one step back762#### env763764Type: `object`\765Default: `process.env`766767Environment key-value pairs.768Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 769why, one step back769Unless 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 770–775why, one step back770771#### extendEnv772773Type: `boolean`\774Default: `true`775Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 776why, one step back776If `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 777–778why, one step back777If `false`, only the `env` option is used, not `process.env`.778Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 779–793why, one step back779#### preferLocal780781Type: `boolean`\782Default: `true` with [`$`](#command), `false` otherwise783784Prefer locally installed binaries when looking for a binary to execute.\785If you `$ npm install foo`, you can then `execa('foo')`.786787#### localDir788789Type: `string | URL`\790Default: `process.cwd()`791792Preferred path to find locally installed binaries in (use with `preferLocal`).793Add `node` option (#804)ehmickybefore adoption663136b
line 794why, one step back794#### nodeFix `stdio` option (#634)ehmickybefore adoption640ae39
line 795why, one step back795Add `node` option (#804)ehmickybefore adoption663136b
lines 796–797why, one step back796Type: `boolean`\797Default: `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwiseFix `stdio` option (#634)ehmickybefore adoption640ae39
line 798why, one step back798Add `node` option (#804)ehmickybefore adoption663136b
line 799why, one step back799If `true`, runs with Node.js. The first argument must be a Node.js file.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 800why, one step back800Add `node` option (#804)ehmickybefore adoption663136b
line 801why, one step back801#### nodeOptionsFix `stdio` option (#634)ehmickybefore adoption640ae39
line 802why, one step back802Add `node` option (#804)ehmickybefore adoption663136b
lines 803–804why, one step back803Type: `string[]`\804Default: [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI options)Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 805why, one step back805Add `node` option (#804)ehmickybefore adoption663136b
line 806why, one step back806List 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 807why, one step back807Add `node` option (#804)ehmickybefore adoption663136b
lines 808–811why, one step back808Requires the [`node`](#node) option to be `true`.809810#### nodePath811Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 812why, one step back812Type: `string | URL`\Add `node` option (#804)ehmickybefore adoption663136b
line 813why, one step back813Default: [`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 814why, one step back814Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
line 815why, one step back815Path to the Node.js executable.Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 816why, one step back816Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
line 817why, one step back817For 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 818–819why, one step back818819Requires the [`node`](#node) option to be `true`.Add `node` option (#804)ehmickybefore adoption663136b
line 820why, one step back820Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 821–822why, one step back821#### verbose822Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
lines 823–824why, one step back823Type: `'none' | 'short' | 'full'`\824Default: `'none'`Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 825why, one step back825Print errors with verbose option (#890)ehmickybefore adoption209f78f
line 826why, one step back826If `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 827why, one step back827Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
lines 828–829why, one step back828If `verbose` is `'full'`, the command's `stdout` and `stderr` are printed too, unless either:829- the [`stdout`](#stdout-1)/[`stderr`](#stderr-1) option is `ignore` or `inherit`.Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 830why, one step back830- 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 831why, one step back831- the [`encoding` option](#encoding) is binary.Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
lines 832–833why, one step back832833This 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 834why, one step back834Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 835–839why, one step back835#### buffer836837Type: `boolean`\838Default: `true`839Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 840why, one step back840Whether to return the subprocess' output using the [`result.stdout`](#stdout), [`result.stderr`](#stderr), [`result.all`](#all-1) and [`result.stdio`](#stdio) properties.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 841why, one step back841Improve `buffer: false` behavior (#747)ehmickybefore adoptiona510995
lines 842–843why, one step back842On failure, the [`error.stdout`](#stdout), [`error.stderr`](#stderr), [`error.all`](#all-1) and [`error.stdio`](#stdio) properties are used instead.843Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 844why, one step back844When `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.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 845–849why, one step back845846#### input847848Type: `string | Uint8Array | stream.Readable`849Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 850why, one step back850Write some input to the subprocess' `stdin`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 851–857why, one step back851852See also the [`inputFile`](#inputfile) and [`stdin`](#stdin) options.853854#### inputFile855856Type: `string | URL`857Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 858why, one step back858Use a file as input to the subprocess' `stdin`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 859–863why, one step back859860See also the [`input`](#input) and [`stdin`](#stdin) options.861862#### stdin863Simplify transforms syntax (#748)ehmickybefore adoptionfd00294
line 864why, one step back864Type: `string | number | stream.Readable | ReadableStream | URL | Uint8Array | Iterable<string> | Iterable<Uint8Array> | Iterable<unknown> | AsyncIterable<string> | AsyncIterable<Uint8Array> | AsyncIterable<unknown> | GeneratorFunction<string> | GeneratorFunction<Uint8Array> | GeneratorFunction<unknown>| AsyncGeneratorFunction<string> | AsyncGeneratorFunction<Uint8Array> | AsyncGeneratorFunction<unknown>` (or a tuple of those types)\Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 865–866why, one step back865Default: `inherit` with [`$`](#command), `pipe` otherwise866Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 867–868why, one step back867[How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard input. This can be:868- `'pipe'`: Sets [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin) stream.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 869–872why, one step back869- `'overlapped'`: Like `'pipe'` but asynchronous on Windows.870- `'ignore'`: Do not use `stdin`.871- `'inherit'`: Re-use the current process' `stdin`.872- an integer: Re-use a specific file descriptor from the current process.Document how to pass a Node.js stream to stdin/stdout/stderr (#644)ehmickybefore adoption2500696
line 873why, one step back873- a [Node.js `Readable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13
line 874why, one step back874- `{ file: 'path' }` object.Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd
lines 875–877why, one step back875- a file URL.876- a web [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream).877- 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 878why, one step back878- an `Uint8Array`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 879why, one step back879Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
lines 880–881why, one step back880This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.881Simplify transforms syntax (#748)ehmickybefore adoptionfd00294
line 882why, one step back882This can also be a generator function to transform the input. [Learn more.](docs/transform.md)Allow passing generators to the `std*` options (#693)ehmickybefore adoptione8f6bbd
line 883why, one step back883Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 884–885why, one step back884#### stdout885Simplify transforms syntax (#748)ehmickybefore adoptionfd00294
line 886why, one step back886Type: `string | number | stream.Writable | WritableStream | URL | GeneratorFunction<string> | GeneratorFunction<Uint8Array> | GeneratorFunction<unknown>| AsyncGeneratorFunction<string> | AsyncGeneratorFunction<Uint8Array> | AsyncGeneratorFunction<unknown>` (or a tuple of those types)\Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 887–888why, one step back887Default: `pipe`888Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 889–890why, one step back889[How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard output. This can be:890- `'pipe'`: Sets [`subprocessResult.stdout`](#stdout) (as a string or `Uint8Array`) and [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout) (as a stream).Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 891–894why, one step back891- `'overlapped'`: Like `'pipe'` but asynchronous on Windows.892- `'ignore'`: Do not use `stdout`.893- `'inherit'`: Re-use the current process' `stdout`.894- an integer: Re-use a specific file descriptor from the current process.Document how to pass a Node.js stream to stdin/stdout/stderr (#644)ehmickybefore adoption2500696
line 895why, one step back895- a [Node.js `Writable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13
line 896why, one step back896- `{ file: 'path' }` object.Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd
lines 897–898why, one step back897- a file URL.898- a web [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream).Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 899why, one step back899Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
lines 900–901why, one step back900This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.901Simplify transforms syntax (#748)ehmickybefore adoptionfd00294
line 902why, one step back902This can also be a generator function to transform the output. [Learn more.](docs/transform.md)Allow passing generators to the `std*` options (#693)ehmickybefore adoptione8f6bbd
line 903why, one step back903Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 904–905why, one step back904#### stderr905Simplify transforms syntax (#748)ehmickybefore adoptionfd00294
line 906why, one step back906Type: `string | number | stream.Writable | WritableStream | URL | GeneratorFunction<string> | GeneratorFunction<Uint8Array> | GeneratorFunction<unknown>| AsyncGeneratorFunction<string> | AsyncGeneratorFunction<Uint8Array> | AsyncGeneratorFunction<unknown>` (or a tuple of those types)\Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 907–908why, one step back907Default: `pipe`908Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 909–910why, one step back909[How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the subprocess' standard error. This can be:910- `'pipe'`: Sets [`subprocessResult.stderr`](#stderr) (as a string or `Uint8Array`) and [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr) (as a stream).Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 911–914why, one step back911- `'overlapped'`: Like `'pipe'` but asynchronous on Windows.912- `'ignore'`: Do not use `stderr`.913- `'inherit'`: Re-use the current process' `stderr`.914- an integer: Re-use a specific file descriptor from the current process.Document how to pass a Node.js stream to stdin/stdout/stderr (#644)ehmickybefore adoption2500696
line 915why, one step back915- a [Node.js `Writable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13
line 916why, one step back916- `{ file: 'path' }` object.Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd
lines 917–918why, one step back917- a file URL.918- a web [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream).Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 919why, one step back919Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
lines 920–921why, one step back920This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.921Simplify transforms syntax (#748)ehmickybefore adoptionfd00294
line 922why, one step back922This can also be a generator function to transform the output. [Learn more.](docs/transform.md)Allow passing generators to the `std*` options (#693)ehmickybefore adoptione8f6bbd
line 923why, one step back923Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 924–925why, one step back924#### stdio925Simplify transforms syntax (#748)ehmickybefore adoptionfd00294
line 926why, one step back926Type: `string | Array<string | number | stream.Readable | stream.Writable | ReadableStream | WritableStream | URL | Uint8Array | Iterable<string> | Iterable<Uint8Array> | Iterable<unknown> | AsyncIterable<string> | AsyncIterable<Uint8Array> | AsyncIterable<unknown> | GeneratorFunction<string> | GeneratorFunction<Uint8Array> | GeneratorFunction<unknown>| AsyncGeneratorFunction<string> | AsyncGeneratorFunction<Uint8Array> | AsyncGeneratorFunction<unknown>>` (or a tuple of those types)\Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 927–928why, one step back927Default: `pipe`928Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
line 929why, one step back929Like 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'}`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 930why, one step back930Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
lines 931–932why, one step back931A single string can be used as a shortcut. For example, `{stdio: 'pipe'}` is the same as `{stdin: 'pipe', stdout: 'pipe', stderr: 'pipe'}`.932Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 933why, one step back933The 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.Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
line 934why, one step back934Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 935–939why, one step back935#### all936937Type: `boolean`\938Default: `false`939Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 940why, one step back940Add 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 941–946why, one step back941942#### lines943944Type: `boolean`\945Default: `false`946Simplify `lines` option (#929)ehmickybefore adoptiond30fcbc
line 947why, one step back947Set [`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 948why, one step back948Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 949why, one step back949This cannot be used if the [`encoding` option](#encoding) is binary.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 950why, one step back950Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 951why, one step back951#### encodingAdd `ipc` option (#794)ehmickybefore adoptionc8a7961
line 952why, one step back952Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 953why, one step back953Type: `string`\Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 954why, one step back954Default: `'utf8'`Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 955why, one step back955Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
lines 956–962why, one step back956If the subprocess outputs text, specifies its character encoding, either `'utf8'` or `'utf16le'`.957958If it outputs binary data instead, this should be either:959- `'buffer'`: returns the binary output as an `Uint8Array`.960- `'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.961962The output is available with [`result.stdout`](#stdout), [`result.stderr`](#stderr) and [`result.stdio`](#stdio).Add `ipc` option (#794)ehmickybefore adoptionc8a7961
line 963why, one step back963Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 964–970why, one step back964#### stripFinalNewline965966Type: `boolean`\967Default: `true`968969Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.970Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 971–972why, one step back971If the [`lines` option](#lines) is true, this applies to each output line instead.972Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 973why, one step back973#### maxBufferFix `stdio` option (#634)ehmickybefore adoption640ae39
line 974why, one step back974Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 975why, one step back975Type: `number`\Improve documentation of `maxBuffer` (#921)ehmickybefore adoptionbedb729
line 976why, one step back976Default: `100_000_000`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 977why, one step back977Improve documentation of `maxBuffer` (#921)ehmickybefore adoptionbedb729
lines 978–984why, one step back978Largest amount of data allowed on [`stdout`](#stdout), [`stderr`](#stderr) and [`stdio`](#stdio).979980This is measured:981- By default: in [characters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length).982- If the [`encoding` option](#encoding) is `'buffer'`: in bytes.983- If the [`lines` option](#lines) is `true`: in lines.984- If a [transform in object mode](docs/transform.md#object-mode) is used: in objects.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 985why, one step back985Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 986why, one step back986#### ipcFix `stdio` option (#634)ehmickybefore adoption640ae39
line 987why, one step back987Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 988why, one step back988Type: `boolean`\Add `node` option (#804)ehmickybefore adoption663136b
line 989why, one step back989Default: `true` if the [`node`](#node) option is enabled, `false` otherwiseFix `stdio` option (#634)ehmickybefore adoption640ae39
line 990why, one step back990Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 991why, one step back991Enables 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).Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 992–995why, one step back992993#### serialization994995Type: `string`\Change default value of `serialization` option to `advanced` (#905)ehmickybefore adoption4577582
line 996why, one step back996Default: `'advanced'`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 997why, one step back997Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 998why, one step back998Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#ipc) option:Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 999–1005why, one step back999 - `json`: Uses `JSON.stringify()` and `JSON.parse()`.1000 - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)10011002[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)10031004#### detached1005Fix incorrect Markdown indentation in `readme.md` (#802)ehmickybefore adoption3bd96ba
lines 1006–1007why, one step back1006Type: `boolean`\1007Default: `false`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1008why, one step back1008Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1009why, one step back1009Prepare 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).Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1010why, one step back1010Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1011why, one step back1011#### cleanupFix `stdio` option (#634)ehmickybefore adoption640ae39
line 1012why, one step back1012Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 1013–1014why, one step back1013Type: `boolean`\1014Default: `true`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1015why, one step back1015Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 1016–1018why, one step back1016Kill the subprocess when the current process exits unless either:1017 - the subprocess is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)1018 - the current process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exitFix `stdio` option (#634)ehmickybefore adoption640ae39
lines 1019–1024why, one step back10191020#### timeout10211022Type: `number`\1023Default: `0`1024Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1025why, one step back1025If `timeout` is greater than `0`, the subprocess will be [terminated](#killsignal) if it runs for longer than that amount of milliseconds.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1026why, one step back1026Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf
line 1027why, one step back1027#### cancelSignalFix `stdio` option (#634)ehmickybefore adoption640ae39
line 1028why, one step back1028Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1029why, one step back1029Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1030why, one step back1030Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1031why, one step back1031You can abort the subprocess using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1032why, one step back1032Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1033why, one step back1033When `AbortController.abort()` is called, [`.isCanceled`](#iscanceled) becomes `true`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1034why, one step back1034Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34
line 1035why, one step back1035#### forceKillAfterDelayImprove graceful exit (#714)ehmickybefore adoption5eeaab5
lines 1036–1039why, one step back10361037Type: `number | false`\1038Default: `5000`1039Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1040why, one step back1040If 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 1041–1043why, one step back10411042The grace period is 5 seconds by default. This feature can be disabled with `false`.1043Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1044why, one step back1044This works when the subprocess is terminated by either:Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf
line 1045why, one step back1045- the [`cancelSignal`](#cancelsignal), [`timeout`](#timeout), [`maxBuffer`](#maxbuffer) or [`cleanup`](#cleanup) optionImprove graceful exit (#714)ehmickybefore adoption5eeaab5
lines 1046–1047why, one step back1046- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with no arguments1047Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1048why, one step back1048This does not work when the subprocess is terminated by either:Improve graceful exit (#714)ehmickybefore adoption5eeaab5
lines 1049–1052why, one step back1049- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with an argument1050- calling [`process.kill(subprocess.pid)`](https://nodejs.org/api/process.html#processkillpid-signal)1051- sending a termination signal from another process1052Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1053why, one step back1053Also, 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 1054why, one step back1054Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1055why, one step back1055#### killSignalFix `stdio` option (#634)ehmickybefore adoption640ae39
line 1056why, one step back1056Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 1057–1058why, one step back1057Type: `string | number`\1058Default: `SIGTERM`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1059why, one step back1059Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1060why, one step back1060Signal used to terminate the subprocess when:Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf
line 1061why, one step back1061- using the [`cancelSignal`](#cancelsignal), [`timeout`](#timeout), [`maxBuffer`](#maxbuffer) or [`cleanup`](#cleanup) optionRe-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1062why, one step back1062- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with no argumentsFix `stdio` option (#634)ehmickybefore adoption640ae39
line 1063why, one step back1063Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1064why, one step back1064This can be either a name (like `"SIGTERM"`) or a number (like `9`).Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1065why, one step back1065Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1066why, one step back1066#### argv0Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1067why, one step back1067Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1068why, one step back1068Type: `string`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1069why, one step back1069Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1070why, one step back1070Explicitly set the value of `argv[0]` sent to the subprocess. This will be set to `file` if not specified.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1071why, one step back1071Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1072why, one step back1072#### uidFix `stdio` option (#634)ehmickybefore adoption640ae39
line 1073why, one step back1073Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1074why, one step back1074Type: `number`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1075why, one step back1075Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1076why, one step back1076Sets the user identity of the subprocess.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1077why, one step back1077Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1078why, one step back1078#### gidFix `stdio` option (#634)ehmickybefore adoption640ae39
line 1079why, one step back1079Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1080why, one step back1080Type: `number`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1081why, one step back1081Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1082why, one step back1082Sets the group identity of the subprocess.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1083why, one step back1083Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1084why, one step back1084#### windowsVerbatimArgumentsFix `stdio` option (#634)ehmickybefore adoption640ae39
line 1085why, one step back1085Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 1086–1087why, one step back1086Type: `boolean`\1087Default: `false`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1088why, one step back1088Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1089why, one step back1089If `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`.Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1090why, one step back1090Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1091why, one step back1091#### windowsHideFix `stdio` option (#634)ehmickybefore adoption640ae39
line 1092why, one step back1092Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
lines 1093–1094why, one step back1093Type: `boolean`\1094Default: `true`Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 1095why, one step back1095Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72
line 1096why, one step back1096On 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.Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 1097–1098why, one step back10971098## TipsAllow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
lines 1099–1105why, one step back10991100### Redirect stdin/stdout/stderr to multiple destinations11011102The [`stdin`](#stdin), [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options can be an array of values.1103The following example redirects `stdout` to both the terminal and an `output.txt` file, while also retrieving its value programmatically.11041105```jsAllow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf
line 1106why, one step back1106const {stdout} = await execa('npm', ['install'], {stdout: ['inherit', './output.txt', 'pipe']});Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
lines 1107–1109why, one step back1107console.log(stdout);1108```1109Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1110why, one step back1110When combining `inherit` with other values, please note that the subprocess will not be an interactive TTY, even if the current process is one.Document how to pass a Node.js stream to stdin/stdout/stderr (#644)ehmickybefore adoption2500696
lines 1111–1124why, one step back11111112### Redirect a Node.js stream from/to stdin/stdout/stderr11131114When 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.11151116```1117TypeError [ERR_INVALID_ARG_VALUE]: The argument 'stdio' is invalid.1118```11191120This limitation can be worked around by passing either:1121 - 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))1122 - `[nodeStream, 'pipe']` instead of `nodeStream`11231124```diffAllow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf
lines 1125–1126why, one step back1125- await execa(..., {stdout: nodeStream});1126+ await execa(..., {stdout: [nodeStream, 'pipe']});Document how to pass a Node.js stream to stdin/stdout/stderr (#644)ehmickybefore adoption2500696
line 1127why, one step back1127```Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 1128–1130why, one step back11281129### Retry on error1130Improve graceful exit (#714)ehmickybefore adoption5eeaab5
line 1131why, one step back1131Safely handle failures by using automatic retries and exponential backoff with the [`p-retry`](https://github.com/sindresorhus/p-retry) package:Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 1132–1143why, one step back11321133```js1134import pRetry from 'p-retry';11351136const run = async () => {1137 const results = await execa('curl', ['-sSL', 'https://sindresorhus.com/unicorn']);1138 return results;1139};11401141console.log(await pRetry(run, {retries: 5}));1142```1143Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1144why, one step back1144### Cancelling a subprocessFix `stdio` option (#634)ehmickybefore adoption640ae39
lines 1145–1149why, one step back11451146```js1147import {execa} from 'execa';11481149const abortController = new AbortController();Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf
line 1150why, one step back1150const subprocess = execa('node', [], {cancelSignal: abortController.signal});Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 1151–1165why, one step back11511152setTimeout(() => {1153 abortController.abort();1154}, 1000);11551156try {1157 await subprocess;1158} catch (error) {1159 console.log(error.isTerminated); // true1160 console.log(error.isCanceled); // true1161}1162```11631164### Execute the current package's binary1165Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0
lines 1166–1167why, one step back1166Execa 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.1167Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 1168–1174why, one step back1168```js1169import {getBinPath} from 'get-bin-path';11701171const binPath = await getBinPath();1172await execa(binPath);1173```1174Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0
line 1175why, one step back1175### Ensuring `all` output is interleavedFix `stdio` option (#634)ehmickybefore adoption640ae39
line 1176why, one step back1176Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0
lines 1177–1178why, one step back1177The `all` [stream](#all) and [string/`Uint8Array`](#all-1) properties are guaranteed to interleave [`stdout`](#stdout) and [`stderr`](#stderr).1178Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 1179why, one step back1179However, for performance reasons, the subprocess might buffer and merge multiple simultaneous writes to `stdout` or `stderr`. This prevents proper interleaving.Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0
lines 1180–1207why, one step back11801181For example, this prints `1 3 2` instead of `1 2 3` because both `console.log()` are merged into a single write.11821183```js1184import {execa} from 'execa';11851186const {all} = await execa('node', ['example.js'], {all: true});1187console.log(all);1188```11891190```js1191// example.js1192console.log('1'); // writes to stdout1193console.error('2'); // writes to stderr1194console.log('3'); // writes to stdout1195```11961197This can be worked around by using `setTimeout()`.11981199```js1200import {setTimeout} from 'timers/promises';12011202console.log('1');1203console.error('2');1204await setTimeout(0);1205console.log('3');1206```1207Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 1208–1209why, one step back1208## Related1209Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0
lines 1210–1211why, one step back1210- [gulp-execa](https://github.com/ehmicky/gulp-execa) - Gulp plugin for Execa1211- [nvexeca](https://github.com/ehmicky/nvexeca) - Run Execa using any Node.js versionFix `stdio` option (#634)ehmickybefore adoption640ae39
lines 1212–1216why, one step back12121213## Maintainers12141215- [Sindre Sorhus](https://github.com/sindresorhus)1216- [@ehmicky](https://github.com/ehmicky)