Skip to content
Myr

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 file

Take 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 back
1<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[![Coverage Status](https://codecov.io/gh/sindresorhus/execa/branch/main/graph/badge.svg)](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 back
34 <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 back
39 </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 back
54- [Cleans up](#cleanup) subprocesses when the current process ends.

Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce

line 55why, one step back
55- 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 back
56- [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 back
57- 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 back
59- 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 back
61- 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 back
62- 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```117

Improve documentation of global script options (#870)ehmickybefore adoption146fa07

line 118why, one step back
118#### Global/shared options

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 119–120why, one step back
119
120```js

Improve documentation of global script options (#870)ehmickybefore adoption146fa07

line 121why, one step back
121import {$ as $_} from 'execa';

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 122why, one step back
122

Improve documentation of global script options (#870)ehmickybefore adoption146fa07

line 123why, one step back
123const $ = $_({stdio: 'inherit'});

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 124why, one step back
124

Improve documentation of global script options (#870)ehmickybefore adoption146fa07

line 125why, one step back
125await $`echo unicorns`;

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 126–127why, one step back
126//=> 'unicorns'
127

Improve documentation of global script options (#870)ehmickybefore adoption146fa07

line 128why, one step back
128await $`echo rainbows`;

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 129–131why, one step back
129//=> 'rainbows'
130```131

`.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562

lines 132–141why, one step back
132#### Piping
133134```js135import {$} from 'execa';136137await $`npm run build`138 .pipe`sort`139 .pipe`head -n2`;140```141

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 142–149why, one step back
142#### Verbose mode
143144```sh145> node file.js146unicorns147rainbows148149> NODE_DEBUG=execa node file.js

Print output with `verbose` option (#884)ehmickybefore adoption6fda30f

line 150why, one step back
150[19:49:00.360] [0] $ echo unicorns

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 151why, one step back
151unicorns

Print process completion with verbose option (#887)ehmickybefore adoption7264bcf

line 152why, one step back
152[19:49:00.383] [0] √ (done in 23ms)

Print output with `verbose` option (#884)ehmickybefore adoption6fda30f

line 153why, one step back
153[19:49:00.383] [1] $ echo rainbows

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 154why, one step back
154rainbows

Print process completion with verbose option (#887)ehmickybefore adoption7264bcf

line 155why, one step back
155[19:49:00.404] [1] √ (done in 21ms)

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 156–165why, one step back
156```
157158### Input/output159160#### Redirect output to a file161162```js163import {execa} from 'execa';164165// Similar to `echo unicorns > stdout.txt` in Bash

Only allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305

line 166why, one step back
166await execa('echo', ['unicorns'], {stdout: {file: 'stdout.txt'}});

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 167–168why, one step back
167
168// Similar to `echo unicorns 2> stdout.txt` in Bash

Only allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305

line 169why, one step back
169await execa('echo', ['unicorns'], {stderr: {file: 'stderr.txt'}});

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 170–171why, one step back
170
171// Similar to `echo unicorns &> stdout.txt` in Bash

Only allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305

line 172why, one step back
172await execa('echo', ['unicorns'], {stdout: {file: 'all.txt'}, stderr: {file: 'all.txt'}});

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 173–185why, one step back
173```
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```185

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 186why, one step back
186#### Save and pipe output from a subprocess

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 187–190why, one step back
187
188```js189import {execa} from 'execa';190

Only allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305

line 191why, one step back
191const {stdout} = await execa('echo', ['unicorns'], {stdout: ['pipe', 'inherit']});

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 192–196why, one step back
192// Prints `unicorns`
193console.log(stdout);194// Also returns 'unicorns'195```196

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 197why, one step back
197#### Pipe multiple subprocesses

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 198–201why, one step back
198
199```js200import {execa} from 'execa';201

Improve piping processes (#834)ehmickybefore adoption1a47ea2

lines 202–203why, one step back
202// Similar to `npm run build | sort | head -n2` in Bash
203const {stdout, pipedFrom} = await execa('npm', ['run', 'build'])

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

lines 204–205why, one step back
204 .pipe('sort')
205 .pipe('head', ['-n2']);

Improve piping processes (#834)ehmickybefore adoption1a47ea2

lines 206–208why, one step back
206console.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 back
209```
210

Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9

lines 211–222why, one step back
211#### Iterate over output lines
212213```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```222

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 223–233why, one step back
223### Handling Errors
224225```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 back
234 ExecaError: Command failed with ENOENT: unknown command
235 spawn unknown ENOENT236 at ...237 at ... {

Add `result|error.durationMs` (#896)ehmickybefore adoption7088091

line 238why, one step back
238 shortMessage: 'Command failed with ENOENT: unknown command\nspawn unknown ENOENT',

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 239–241why, one step back
239 originalMessage: 'spawn unknown ENOENT',
240 command: 'unknown command',241 escapedCommand: 'unknown command',

Add `result|error.durationMs` (#896)ehmickybefore adoption7088091

lines 242–243why, one step back
242 cwd: '/path/to/cwd',
243 durationMs: 28.217566,

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 244–246why, one step back
244 failed: true,
245 timedOut: false,246 isCanceled: false,

Add `result|error.durationMs` (#896)ehmickybefore adoption7088091

line 247why, one step back
247 isTerminated: false,

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 248why, one step back
248 code: 'ENOENT',

Add `result|error.durationMs` (#896)ehmickybefore adoption7088091

lines 249–252why, one step back
249 stdout: '',
250 stderr: '',251 stdio: [undefined, '', ''],252 pipedFrom: []

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

lines 253–261why, one step back
253 [cause]: Error: spawn unknown ENOENT
254 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 back
262 }
263 */264}265```266267## API268269### Methods270271#### execa(file, arguments?, options?)272

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 273–275why, one step back
273`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 back
276_Returns_: [`Subprocess`](#subprocess)

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 277why, one step back
277

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 278–279why, one step back
278Executes a command using `file ...arguments`.
279

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 280–284why, one step back
280Arguments 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 back
285#### $(options)\`command\`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 286why, one step back
286

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 287–288why, one step back
287`command`: `string`\
288`options`: [`Options`](#options-1)\

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 289why, one step back
289_Returns_: [`Subprocess`](#subprocess)

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 290why, one step back
290

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

line 291why, one step back
291Executes a command. The `command` string includes both the `file` and its `arguments`.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 292why, one step back
292

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 293–294why, one step back
293Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces, tabs and newlines must use `${}` like `` $`echo ${'has space'}` ``.
294

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 295–296why, one step back
295This is the preferred method when executing multiple commands in a script file.
296

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 297why, one step back
297The `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 back
298

Allow newlines in `$` (#843)ehmickybefore adoption1315486

lines 299–300why, one step back
299The `command` string can use [multiple lines and indentation](docs/scripts.md#multiline-commands).
300

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 301–304why, one step back
301For more information, please see [this section](#scripts-interface) and [this page](docs/scripts.md).
302303#### $(options)304

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 305–306why, one step back
305`options`: [`Options`](#options-1)\
306_Returns_: [`$`](#command)

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 307why, one step back
307

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 308–309why, one step back
308Returns a new instance of [`$`](#command) but with different default [`options`](#options-1). Consecutive calls are merged to previous ones.
309

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 310–315why, one step back
310This 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?)315

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 316–317why, one step back
316`command`: `string`\
317`options`: [`Options`](#options-1)\

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 318why, one step back
318_Returns_: [`Subprocess`](#subprocess)

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 319why, one step back
319

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 320–321why, one step back
320Executes a command. The `command` string includes both the `file` and its `arguments`.
321

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 322–325why, one step back
322Arguments 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.325

Add `node` option (#804)ehmickybefore adoption663136b

lines 326–327why, one step back
326#### execaNode(scriptPath, arguments?, options?)
327

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 328–330why, one step back
328`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 back
331_Returns_: [`Subprocess`](#subprocess)

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

line 332why, one step back
332

Add `node` option (#804)ehmickybefore adoption663136b

lines 333–336why, one step back
333Same as [`execa()`](#execacommandcommand-options) but using the [`node`](#node) option.
334335Executes a Node.js file using `node scriptPath ...arguments`.336

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

line 337why, one step back
337This is the preferred method when executing Node.js files.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 338why, one step back
338

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 339–340why, one step back
339#### execaSync(file, arguments?, options?)
340#### execaCommandSync(command, options?)

Fix incorrect Markdown indentation in `readme.md` (#802)ehmickybefore adoption3bd96ba

lines 341–342why, one step back
341#### $.sync\`command\`
342#### $.s\`command\`

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

lines 343–344why, one step back
343#### $.sync(options)\`command\`
344#### $.s(options)\`command\`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 345why, one step back
345

Improve documentation of main methods (#860)ehmickybefore adoption3bb0d61

line 346why, one step back
346Same as [`execa()`](#execacommandcommand-options), [`execaCommand()`](#execacommand-command-options), [$\`command\`](#command) but synchronous.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 347why, one step back
347

Print output with `verbose` option (#884)ehmickybefore adoption6fda30f

line 348why, one step back
348Cannot 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 back
349

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 350why, one step back
350Returns 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 back
351
352### 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.355

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 356why, one step back
356### subprocess

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 357–358why, one step back
357
358The return value of all [asynchronous methods](#methods) is both:

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 359why, one step back
359- a `Promise` resolving or rejecting with a [`subprocessResult`](#subprocessResult).

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 360–365why, one step back
360- 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`365

Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0

line 366why, one step back
366Stream [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 back
367
368This 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 back
370- 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 back
371

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

line 372why, one step back
372#### pipe(file, arguments?, options?)

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 373why, one step back
373

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

lines 374–376why, one step back
374`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 back
377_Returns_: [`Promise<SubprocessResult>`](#subprocessresult)

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 378why, one step back
378

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 379why, one step back
379[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 back
380

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

lines 381–382why, one step back
381This 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.
382

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 383why, one step back
383This can be called multiple times to chain a series of subprocesses.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 384why, one step back
384

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 385why, one step back
385Multiple 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 back
386

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 387why, one step back
387This is usually the preferred method to pipe subprocesses.

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

line 388why, one step back
388

Fix Markdown typo (#869)ehmickybefore adoptionc8ba426

lines 389–390why, one step back
389#### pipe\`command\`
390#### pipe(options)\`command\`

`.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562

line 391why, one step back
391

Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86

lines 392–393why, one step back
392`command`: `string`\
393`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 394why, one step back
394_Returns_: [`Promise<SubprocessResult>`](#subprocessresult)

`.pipe()` shortcut for `$` (#840)ehmickybefore adoption316f562

line 395why, one step back
395

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

line 396why, one step back
396Like [`.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 back
397

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 398why, one step back
398This is the preferred method to pipe subprocesses when using [`$`](#command).

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

line 399why, one step back
399

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 400why, one step back
400#### pipe(secondSubprocess, pipeOptions?)

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

line 401why, one step back
401

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 402why, one step back
402`secondSubprocess`: [`execa()` return value](#subprocess)\

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

line 403why, one step back
403`pipeOptions`: [`PipeOptions`](#pipeoptions)\

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 404why, one step back
404_Returns_: [`Promise<SubprocessResult>`](#subprocessresult)

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

line 405why, one step back
405

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 406why, one step back
406Like [`.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 back
407

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 408why, one step back
408This 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 back
409

Improve piping processes (#834)ehmickybefore adoption1a47ea2

line 410why, one step back
410##### pipeOptions

Only allow child processes as argument to `.pipeStdout()` (#752)ehmickybefore adoptiond16c305

line 411why, one step back
411

Improve piping processes (#834)ehmickybefore adoption1a47ea2

lines 412–415why, one step back
412Type: `object`
413414##### pipeOptions.from415

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

line 416why, one step back
416Type: `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\

Improve piping processes (#834)ehmickybefore adoption1a47ea2

lines 417–418why, one step back
417Default: `"stdout"`
418

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

line 419why, one step back
419Which 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 back
420
421`"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 back
422
423##### pipeOptions.to424

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

line 425why, one step back
425Type: `"stdin" | "fd3" | "fd4" | ...`\

Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2

lines 426–427why, one step back
426Default: `"stdin"`
427

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

line 428why, one step back
428Which 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 back
429

Rename `signal` option to `unpipeSignal` (#852)ehmickybefore adoption9dc1141

line 430why, one step back
430##### pipeOptions.unpipeSignal

Improve piping processes (#834)ehmickybefore adoption1a47ea2

lines 431–433why, one step back
431
432Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)433

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 434why, one step back
434Unpipe the subprocess when the signal aborts.

Improve piping processes (#834)ehmickybefore adoption1a47ea2

line 435why, one step back
435

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

line 436why, one step back
436The [`.pipe()`](#pipefile-arguments-options) method will be rejected with a cancellation error.

Improve piping processes (#834)ehmickybefore adoption1a47ea2

line 437why, one step back
437

Add `.kill(signal, error)` (#836)ehmickybefore adoption30a662d

lines 438–439why, one step back
438#### kill(signal, error?)
439#### kill(error?)

Add `.kill(error)` (#811)ehmickybefore adoption9cbb817

line 440why, one step back
440

Add `.kill(signal, error)` (#836)ehmickybefore adoption30a662d

lines 441–442why, one step back
441`signal`: `string | number`\
442`error`: `Error`\

Add `.kill(error)` (#811)ehmickybefore adoption9cbb817

lines 443–444why, one step back
443_Returns_: `boolean`
444

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 445why, one step back
445Sends 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 back
446

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 447why, one step back
447This 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 back
448

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 449why, one step back
449When 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 back
450
451[More info.](https://nodejs.org/api/child_process.html#subprocesskillsignal)452

Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9

lines 453–467why, one step back
453#### [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.467

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

line 468why, one step back
468#### readable(readableOptions?)

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

line 469why, one step back
469

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

line 470why, one step back
470`readableOptions`: [`ReadableOptions`](#readableoptions)\

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

lines 471–476why, one step back
471_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream
472473Converts 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.476

Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9

line 477why, one step back
477Before 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 back
478

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

line 479why, one step back
479#### writable(writableOptions?)

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

line 480why, one step back
480

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

line 481why, one step back
481`writableOptions`: [`WritableOptions`](#writableoptions)\

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

lines 482–487why, one step back
482_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream
483484Converts 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.487

Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9

line 488why, one step back
488Before 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 back
489

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

line 490why, one step back
490#### duplex(duplexOptions?)

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

line 491why, one step back
491

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

line 492why, one step back
492`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

lines 493–498why, one step back
493_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream
494495Converts 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.498

Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9

line 499why, one step back
499Before 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 back
500

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

line 501why, one step back
501##### readableOptions

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

lines 502–504why, one step back
502
503Type: `object`504

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

line 505why, one step back
505##### readableOptions.from

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

line 506why, one step back
506

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

line 507why, one step back
507Type: `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

lines 508–509why, one step back
508Default: `"stdout"`
509

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

line 510why, one step back
510Which 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 back
511
512`"all"` reads both `stdout` and `stderr`. This requires the [`all` option](#all-2) to be `true`.513

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

line 514why, one step back
514##### readableOptions.binary

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

line 515why, one step back
515

Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd

lines 516–517why, one step back
516Type: `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 back
518

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

lines 519–520why, one step back
519If `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).
520

Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9

line 521why, one step back
521If `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 back
522

Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf

line 523why, one step back
523This is always `true` when the [`encoding` option](#encoding) is binary.

Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9

line 524why, one step back
524

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

lines 525–527why, one step back
525##### readableOptions.preserveNewlines
526527Type: `boolean`\

Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9

line 528why, one step back
528Default: `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 back
529
530If both this option and the [`binary` option](#readableoptionsbinary) is `false`, newlines are stripped from each line.531532##### writableOptions533534Type: `object`535536##### writableOptions.to537

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

line 538why, one step back
538Type: `"stdin" | "fd3" | "fd4" | ...`\

Add `.readable()`, `.writable()` and `.duplex()` methods (#912)ehmickybefore adoption666f7f9

lines 539–540why, one step back
539Default: `"stdin"`
540

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

line 541why, one step back
541Which 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 back
542

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 543why, one step back
543### SubprocessResult

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 544–546why, one step back
544
545Type: `object`546

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 547why, one step back
547Result of a subprocess execution.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 548why, one step back
548

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 549why, one step back
549When the subprocess [fails](#failed), it is rejected with an [`ExecaError`](#execaerror) instead.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 550–556why, one step back
550
551#### command552553Type: `string`554555The file and arguments that were run, for logging purposes.556

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 557why, one step back
557This 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 back
558
559#### escapedCommand560561Type: `string`562563Same as [`command`](#command-1) but escaped.564

Better escaping of `result.escapedCommand` (#875)ehmickybefore adoption7b044bb

lines 565–567why, one step back
565Unlike `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 back
568Since 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 back
569

Re-order return value properties (#801)ehmickybefore adoption72836f3

line 570why, one step back
570#### cwd

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 571why, one step back
571

Re-order return value properties (#801)ehmickybefore adoption72836f3

line 572why, one step back
572Type: `string`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 573why, one step back
573

Improve `cwd` option (#803)ehmickybefore adoption2fd9351

line 574why, one step back
574The [current directory](#cwd-1) in which the command was run.

Add `result|error.durationMs` (#896)ehmickybefore adoption7088091

lines 575–579why, one step back
575
576#### durationMs577578Type: `number`579

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 580why, one step back
580Duration of the subprocess, in milliseconds.

Document and type `exitCode` being `undefined` (#680)ehmickybefore adoption95e5754

line 581why, one step back
581

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 582–583why, one step back
582#### stdout
583

Line-wise standard streams (#741)ehmickybefore adoption479d12e

line 584why, one step back
584Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 585why, one step back
585

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 586why, one step back
586The output of the subprocess on `stdout`.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 587why, one step back
587

Improve piping processes (#834)ehmickybefore adoption1a47ea2

line 588why, one step back
588This 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 back
589
590#### stderr591

Line-wise standard streams (#741)ehmickybefore adoption479d12e

line 592why, one step back
592Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 593why, one step back
593

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 594why, one step back
594The output of the subprocess on `stderr`.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 595why, one step back
595

Improve piping processes (#834)ehmickybefore adoption1a47ea2

line 596why, one step back
596This 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 back
597
598#### all599

Line-wise standard streams (#741)ehmickybefore adoption479d12e

line 600why, one step back
600Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 601why, one step back
601

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 602why, one step back
602The 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 back
603
604This 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 back
606- 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 back
607

Improve piping processes (#834)ehmickybefore adoption1a47ea2

line 608why, one step back
608This 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 back
609

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

lines 610–611why, one step back
610#### stdio
611

Line-wise standard streams (#741)ehmickybefore adoption479d12e

line 612why, one step back
612Type: `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 613why, one step back
613

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 614why, one step back
614The 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 back
615

Add `ipc` option (#794)ehmickybefore adoptionc8a7961

line 616why, one step back
616Items 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 back
617

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 618–621why, one step back
618#### failed
619620Type: `boolean`621

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 622why, one step back
622Whether the subprocess failed to run.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 623–627why, one step back
623
624#### timedOut625626Type: `boolean`627

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 628why, one step back
628Whether the subprocess timed out.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 629–633why, one step back
629
630#### isCanceled631632Type: `boolean`633

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 634why, one step back
634Whether the subprocess was canceled using the [`cancelSignal`](#cancelsignal) option.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 635–639why, one step back
635
636#### isTerminated637638Type: `boolean`639

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 640why, one step back
640Whether the subprocess was terminated by a signal (like `SIGTERM`) sent by either:

Improve process termination (#724)ehmickybefore adoption1c48d37

lines 641–642why, one step back
641- 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 back
643

Re-order return value properties (#801)ehmickybefore adoption72836f3

lines 644–647why, one step back
644#### exitCode
645646Type: `number | undefined`647

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 648why, one step back
648The numeric exit code of the subprocess that was run.

Re-order return value properties (#801)ehmickybefore adoption72836f3

line 649why, one step back
649

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 650why, one step back
650This 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 back
651

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 652–655why, one step back
652#### signal
653654Type: `string | undefined`655

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 656why, one step back
656The name of the signal (like `SIGTERM`) that terminated the subprocess, sent by either:

Improve process termination (#724)ehmickybefore adoption1c48d37

lines 657–658why, one step back
657- 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 back
659

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 660why, one step back
660If 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 back
661
662#### signalDescription663664Type: `string | undefined`665

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 666why, one step back
666A 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 back
667

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 668why, one step back
668If 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 back
669
670#### pipedFrom671

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 672why, one step back
672Type: [`Array<SubprocessResult | ExecaError>`](#subprocessresult)

Improve piping processes (#834)ehmickybefore adoption1a47ea2

line 673why, one step back
673

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 674why, one step back
674Results 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 back
675

Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d

line 676why, one step back
676This 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 back
677

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

lines 678–727why, one step back
678### ExecaError
679### 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.727

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 728–731why, one step back
728### options
729730Type: `object`731

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 732why, one step back
732This 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 back
733

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

lines 734–735why, one step back
734#### reject
735

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 736–738why, one step back
736Type: `boolean`\
737Default: `true`738

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 739why, one step back
739Setting this to `false` resolves the promise with the [error](#execaerror) instead of rejecting it.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 740why, one step back
740

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

lines 741–757why, one step back
741#### shell
742743Type: `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()`757

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 758why, one step back
758Current working directory of the subprocess.

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 759why, one step back
759

Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c

line 760why, one step back
760This 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 back
761

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

lines 762–768why, one step back
762#### env
763764Type: `object`\765Default: `process.env`766767Environment key-value pairs.768

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 769why, one step back
769Unless 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 back
770
771#### extendEnv772773Type: `boolean`\774Default: `true`775

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 776why, one step back
776If `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 back
777If `false`, only the `env` option is used, not `process.env`.
778

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 779–793why, one step back
779#### preferLocal
780781Type: `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`).793

Add `node` option (#804)ehmickybefore adoption663136b

line 794why, one step back
794#### node

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 795why, one step back
795

Add `node` option (#804)ehmickybefore adoption663136b

lines 796–797why, one step back
796Type: `boolean`\
797Default: `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwise

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 798why, one step back
798

Add `node` option (#804)ehmickybefore adoption663136b

line 799why, one step back
799If `true`, runs with Node.js. The first argument must be a Node.js file.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 800why, one step back
800

Add `node` option (#804)ehmickybefore adoption663136b

line 801why, one step back
801#### nodeOptions

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 802why, one step back
802

Add `node` option (#804)ehmickybefore adoption663136b

lines 803–804why, one step back
803Type: `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 back
805

Add `node` option (#804)ehmickybefore adoption663136b

line 806why, one step back
806List 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 back
807

Add `node` option (#804)ehmickybefore adoption663136b

lines 808–811why, one step back
808Requires the [`node`](#node) option to be `true`.
809810#### nodePath811

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 812why, one step back
812Type: `string | URL`\

Add `node` option (#804)ehmickybefore adoption663136b

line 813why, one step back
813Default: [`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 back
814

Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c

line 815why, one step back
815Path to the Node.js executable.

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 816why, one step back
816

Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c

line 817why, one step back
817For 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 back
818
819Requires the [`node`](#node) option to be `true`.

Add `node` option (#804)ehmickybefore adoption663136b

line 820why, one step back
820

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

lines 821–822why, one step back
821#### verbose
822

Print output with `verbose` option (#884)ehmickybefore adoption6fda30f

lines 823–824why, one step back
823Type: `'none' | 'short' | 'full'`\
824Default: `'none'`

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 825why, one step back
825

Print errors with verbose option (#890)ehmickybefore adoption209f78f

line 826why, one step back
826If `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 back
827

Print output with `verbose` option (#884)ehmickybefore adoption6fda30f

lines 828–829why, one step back
828If `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 back
830- 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 back
831- the [`encoding` option](#encoding) is binary.

Print output with `verbose` option (#884)ehmickybefore adoption6fda30f

lines 832–833why, one step back
832
833This 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 back
834

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 835–839why, one step back
835#### buffer
836837Type: `boolean`\838Default: `true`839

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 840why, one step back
840Whether 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 back
841

Improve `buffer: false` behavior (#747)ehmickybefore adoptiona510995

lines 842–843why, one step back
842On failure, the [`error.stdout`](#stdout), [`error.stderr`](#stderr), [`error.all`](#all-1) and [`error.stdio`](#stdio) properties are used instead.
843

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 844why, one step back
844When `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 back
845
846#### input847848Type: `string | Uint8Array | stream.Readable`849

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 850why, one step back
850Write some input to the subprocess' `stdin`.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 851–857why, one step back
851
852See also the [`inputFile`](#inputfile) and [`stdin`](#stdin) options.853854#### inputFile855856Type: `string | URL`857

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 858why, one step back
858Use a file as input to the subprocess' `stdin`.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 859–863why, one step back
859
860See also the [`input`](#input) and [`stdin`](#stdin) options.861862#### stdin863

Simplify transforms syntax (#748)ehmickybefore adoptionfd00294

line 864why, one step back
864Type: `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 back
865Default: `inherit` with [`$`](#command), `pipe` otherwise
866

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 867–868why, one step back
867[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 back
869- `'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 back
873- a [Node.js `Readable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).

Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13

line 874why, one step back
874- `{ file: 'path' }` object.

Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd

lines 875–877why, one step back
875- 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 back
878- an `Uint8Array`.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 879why, one step back
879

Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c

lines 880–881why, one step back
880This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.
881

Simplify transforms syntax (#748)ehmickybefore adoptionfd00294

line 882why, one step back
882This 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 back
883

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 884–885why, one step back
884#### stdout
885

Simplify transforms syntax (#748)ehmickybefore adoptionfd00294

line 886why, one step back
886Type: `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 back
887Default: `pipe`
888

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 889–890why, one step back
889[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 back
891- `'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 back
895- a [Node.js `Writable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).

Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13

line 896why, one step back
896- `{ file: 'path' }` object.

Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd

lines 897–898why, one step back
897- 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 back
899

Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c

lines 900–901why, one step back
900This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.
901

Simplify transforms syntax (#748)ehmickybefore adoptionfd00294

line 902why, one step back
902This 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 back
903

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 904–905why, one step back
904#### stderr
905

Simplify transforms syntax (#748)ehmickybefore adoptionfd00294

line 906why, one step back
906Type: `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 back
907Default: `pipe`
908

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 909–910why, one step back
909[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 back
911- `'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 back
915- a [Node.js `Writable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).

Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13

line 916why, one step back
916- `{ file: 'path' }` object.

Improve documentation of synchronous methods (#669)ehmickybefore adoptionb11cbcd

lines 917–918why, one step back
917- 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 back
919

Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c

lines 920–921why, one step back
920This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.
921

Simplify transforms syntax (#748)ehmickybefore adoptionfd00294

line 922why, one step back
922This 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 back
923

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 924–925why, one step back
924#### stdio
925

Simplify transforms syntax (#748)ehmickybefore adoptionfd00294

line 926why, one step back
926Type: `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 back
927Default: `pipe`
928

Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c

line 929why, one step back
929Like 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 back
930

Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c

lines 931–932why, one step back
931A single string can be used as a shortcut. For example, `{stdio: 'pipe'}` is the same as `{stdin: 'pipe', stdout: 'pipe', stderr: 'pipe'}`.
932

Add `ipc` option (#794)ehmickybefore adoptionc8a7961

line 933why, one step back
933The 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 back
934

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 935–939why, one step back
935#### all
936937Type: `boolean`\938Default: `false`939

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 940why, one step back
940Add 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 back
941
942#### lines943944Type: `boolean`\945Default: `false`946

Simplify `lines` option (#929)ehmickybefore adoptiond30fcbc

line 947why, one step back
947Set [`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 back
948

Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf

line 949why, one step back
949This cannot be used if the [`encoding` option](#encoding) is binary.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 950why, one step back
950

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 951why, one step back
951#### encoding

Add `ipc` option (#794)ehmickybefore adoptionc8a7961

line 952why, one step back
952

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 953why, one step back
953Type: `string`\

Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf

line 954why, one step back
954Default: `'utf8'`

Add `ipc` option (#794)ehmickybefore adoptionc8a7961

line 955why, one step back
955

Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf

lines 956–962why, one step back
956If 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 back
963

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 964–970why, one step back
964#### stripFinalNewline
965966Type: `boolean`\967Default: `true`968969Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.970

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 971–972why, one step back
971If the [`lines` option](#lines) is true, this applies to each output line instead.
972

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 973why, one step back
973#### maxBuffer

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 974why, one step back
974

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 975why, one step back
975Type: `number`\

Improve documentation of `maxBuffer` (#921)ehmickybefore adoptionbedb729

line 976why, one step back
976Default: `100_000_000`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 977why, one step back
977

Improve documentation of `maxBuffer` (#921)ehmickybefore adoptionbedb729

lines 978–984why, one step back
978Largest 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 back
985

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 986why, one step back
986#### ipc

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 987why, one step back
987

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 988why, one step back
988Type: `boolean`\

Add `node` option (#804)ehmickybefore adoption663136b

line 989why, one step back
989Default: `true` if the [`node`](#node) option is enabled, `false` otherwise

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 990why, one step back
990

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 991why, one step back
991Enables 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 back
992
993#### serialization994995Type: `string`\

Change default value of `serialization` option to `advanced` (#905)ehmickybefore adoption4577582

line 996why, one step back
996Default: `'advanced'`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 997why, one step back
997

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 998why, one step back
998Specify 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 back
999 - `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#### detached1005

Fix incorrect Markdown indentation in `readme.md` (#802)ehmickybefore adoption3bd96ba

lines 1006–1007why, one step back
1006Type: `boolean`\
1007Default: `false`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1008why, one step back
1008

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1009why, one step back
1009Prepare 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 back
1010

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1011why, one step back
1011#### cleanup

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1012why, one step back
1012

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

lines 1013–1014why, one step back
1013Type: `boolean`\
1014Default: `true`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1015why, one step back
1015

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 1016–1018why, one step back
1016Kill 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 exit

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 1019–1024why, one step back
1019
1020#### timeout10211022Type: `number`\1023Default: `0`1024

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1025why, one step back
1025If `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 back
1026

Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf

line 1027why, one step back
1027#### cancelSignal

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1028why, one step back
1028

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1029why, one step back
1029Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1030why, one step back
1030

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1031why, one step back
1031You 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 back
1032

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1033why, one step back
1033When `AbortController.abort()` is called, [`.isCanceled`](#iscanceled) becomes `true`.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1034why, one step back
1034

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

line 1035why, one step back
1035#### forceKillAfterDelay

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 1036–1039why, one step back
1036
1037Type: `number | false`\1038Default: `5000`1039

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1040why, one step back
1040If 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 back
1041
1042The grace period is 5 seconds by default. This feature can be disabled with `false`.1043

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1044why, one step back
1044This works when the subprocess is terminated by either:

Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf

line 1045why, one step back
1045- the [`cancelSignal`](#cancelsignal), [`timeout`](#timeout), [`maxBuffer`](#maxbuffer) or [`cleanup`](#cleanup) option

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 1046–1047why, one step back
1046- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with no arguments
1047

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1048why, one step back
1048This does not work when the subprocess is terminated by either:

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 1049–1052why, one step back
1049- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with an argument
1050- calling [`process.kill(subprocess.pid)`](https://nodejs.org/api/process.html#processkillpid-signal)1051- sending a termination signal from another process1052

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1053why, one step back
1053Also, 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 back
1054

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1055why, one step back
1055#### killSignal

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1056why, one step back
1056

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

lines 1057–1058why, one step back
1057Type: `string | number`\
1058Default: `SIGTERM`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1059why, one step back
1059

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1060why, one step back
1060Signal used to terminate the subprocess when:

Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf

line 1061why, one step back
1061- using the [`cancelSignal`](#cancelsignal), [`timeout`](#timeout), [`maxBuffer`](#maxbuffer) or [`cleanup`](#cleanup) option

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1062why, one step back
1062- calling [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal) with no arguments

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1063why, one step back
1063

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1064why, one step back
1064This can be either a name (like `"SIGTERM"`) or a number (like `9`).

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1065why, one step back
1065

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1066why, one step back
1066#### argv0

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1067why, one step back
1067

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1068why, one step back
1068Type: `string`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1069why, one step back
1069

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1070why, one step back
1070Explicitly 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 back
1071

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1072why, one step back
1072#### uid

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1073why, one step back
1073

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1074why, one step back
1074Type: `number`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1075why, one step back
1075

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1076why, one step back
1076Sets the user identity of the subprocess.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1077why, one step back
1077

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1078why, one step back
1078#### gid

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1079why, one step back
1079

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1080why, one step back
1080Type: `number`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1081why, one step back
1081

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1082why, one step back
1082Sets the group identity of the subprocess.

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1083why, one step back
1083

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1084why, one step back
1084#### windowsVerbatimArguments

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1085why, one step back
1085

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

lines 1086–1087why, one step back
1086Type: `boolean`\
1087Default: `false`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1088why, one step back
1088

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1089why, one step back
1089If `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 back
1090

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1091why, one step back
1091#### windowsHide

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1092why, one step back
1092

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

lines 1093–1094why, one step back
1093Type: `boolean`\
1094Default: `true`

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1095why, one step back
1095

Re-order options in `readme.md` (#800)ehmickybefore adoption97caf72

line 1096why, one step back
1096On 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 back
1097
1098## Tips

Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c

lines 1099–1105why, one step back
1099
1100### 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```js

Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf

line 1106why, one step back
1106const {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 back
1107console.log(stdout);
1108```1109

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1110why, one step back
1110When 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 back
1111
1112### 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```diff

Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf

lines 1125–1126why, one step back
1125- 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 back
1127```

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 1128–1130why, one step back
1128
1129### Retry on error1130

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

line 1131why, one step back
1131Safely 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 back
1132
1133```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```1143

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1144why, one step back
1144### Cancelling a subprocess

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 1145–1149why, one step back
1145
1146```js1147import {execa} from 'execa';11481149const abortController = new AbortController();

Rename `signal` option to `cancelSignal` (#880)ehmickybefore adoption231beaf

line 1150why, one step back
1150const subprocess = execa('node', [], {cancelSignal: abortController.signal});

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 1151–1165why, one step back
1151
1152setTimeout(() => {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 binary1165

Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0

lines 1166–1167why, one step back
1166Execa 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.
1167

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 1168–1174why, one step back
1168```js
1169import {getBinPath} from 'get-bin-path';11701171const binPath = await getBinPath();1172await execa(binPath);1173```1174

Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0

line 1175why, one step back
1175### Ensuring `all` output is interleaved

Fix `stdio` option (#634)ehmickybefore adoption640ae39

line 1176why, one step back
1176

Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0

lines 1177–1178why, one step back
1177The `all` [stream](#all) and [string/`Uint8Array`](#all-1) properties are guaranteed to interleave [`stdout`](#stdout) and [`stderr`](#stderr).
1178

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 1179why, one step back
1179However, 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 back
1180
1181For 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```1207

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 1208–1209why, one step back
1208## Related
1209

Document workaround for proper `all` interleaving (#640)ehmickybefore adoption21d69c0

lines 1210–1211why, one step back
1210- [gulp-execa](https://github.com/ehmicky/gulp-execa) - Gulp plugin for Execa
1211- [nvexeca](https://github.com/ehmicky/nvexeca) - Run Execa using any Node.js version

Fix `stdio` option (#634)ehmickybefore adoption640ae39

lines 1212–1216why, one step back
1212
1213## Maintainers12141215- [Sindre Sorhus](https://github.com/sindresorhus)1216- [@ehmicky](https://github.com/ehmicky)