Skip to content
Myr

Re-order sections in API reference (#994)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent 8b92f47 · Browse files · 4 files+351 added−351 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+351 added−351 removed

  • other:+351 added−351 removed

4 files+351 added−351 removed

modified:types/arguments/options.d.ts+123 added-123 removed
25 unmodified lines
26 */27 readonly node?: boolean;2829 /**30 List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.3132 Requires the `node` option to be `true`.3334 @default [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI options)35 */36 readonly nodeOptions?: readonly string[];3738 /**39 Path to the Node.js executable.4041 Requires the `node` option to be `true`.42
1 unmodified line
44 */45 readonly nodePath?: string | URL;4647 /**39 List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.48 If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).4941 Requires the `node` option to be `true`.50 Uses [`/bin/sh`](https://en.wikipedia.org/wiki/Unix_shell) on UNIX and [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.5143 @default [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI options)52 We recommend against using this option.5354 @default false55 */45 readonly nodeOptions?: readonly string[];56 readonly shell?: boolean | string | URL;5758 /**59 Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.6061 This is also used to resolve the `nodePath` option when it is a relative path.6263 @default process.cwd()64 */65 readonly cwd?: string | URL;6667 /**68 [Environment variables](https://en.wikipedia.org/wiki/Environment_variable).6970 Unless the `extendEnv` option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).7172 @default [process.env](https://nodejs.org/api/process.html#processenv)73 */74 readonly env?: NodeJS.ProcessEnv;7576 /**77 If `true`, the subprocess uses both the `env` option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).78 If `false`, only the `env` option is used, not `process.env`.7980 @default true81 */82 readonly extendEnv?: boolean;8384 /**85 Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).8687 See also the `inputFile` and `stdin` options.88 */
44 unmodified lines
133 */134 readonly stdio?: StdioOptionsProperty<IsSync>;135136 /**137 Add a `subprocess.all` stream and a `result.all` property. They contain the combined/interleaved output of the subprocess' `stdout` and `stderr`.138139 @default false140 */141 readonly all?: boolean;142143 /**144 If the subprocess outputs text, specifies its character encoding, either [`'utf8'`](https://en.wikipedia.org/wiki/UTF-8) or [`'utf16le'`](https://en.wikipedia.org/wiki/UTF-16).145146 If it outputs binary data instead, this should be either:147 - `'buffer'`: returns the binary output as an `Uint8Array`.148 - [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64), [`'base64url'`](https://en.wikipedia.org/wiki/Base64#URL_applications), [`'latin1'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings) or [`'ascii'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings): encodes the binary output as a string.149150 The output is available with `result.stdout`, `result.stderr` and `result.stdio`.151152 @default 'utf8'153 */154 readonly encoding?: EncodingOption;155156 /**157 Set `result.stdout`, `result.stderr`, `result.all` and `result.stdio` as arrays of strings, splitting the subprocess' output into lines.158159 This cannot be used if the `encoding` option is binary.160
3 unmodified lines
164 */165 readonly lines?: FdGenericOption<boolean>;166167 /**111 Setting this to `false` resolves the result's promise with the error instead of rejecting it.112113 @default true114 */115 readonly reject?: boolean;116117 /**168 Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.169170 If the `lines` option is true, this applies to each output line instead.171
3 unmodified lines
175 */176 readonly stripFinalNewline?: FdGenericOption<boolean>;177178 /**129 If `true`, the subprocess uses both the `env` option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).130 If `false`, only the `env` option is used, not `process.env`.179 Largest amount of data allowed on `stdout`, `stderr` and `stdio`.180132 @default true133 */134 readonly extendEnv?: boolean;181 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.182136 /**137 Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.138139 This is also used to resolve the `nodePath` option when it is a relative path.140141 @default process.cwd()183 @default 100_000_000184 */143 readonly cwd?: string | URL;185 readonly maxBuffer?: FdGenericOption<number>;186187 /**146 [Environment variables](https://en.wikipedia.org/wiki/Environment_variable).188 When `buffer` is `false`, the `result.stdout`, `result.stderr`, `result.all` and `result.stdio` properties are not set.189148 Unless the `extendEnv` option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).190 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.191150 @default [process.env](https://nodejs.org/api/process.html#processenv)192 @default true193 */152 readonly env?: NodeJS.ProcessEnv;194 readonly buffer?: FdGenericOption<boolean>;195196 /**155 Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.197 Enables exchanging messages with the subprocess using `subprocess.send(message)` and `subprocess.on('message', (message) => {})`.198157 @default file being executed199 @default `true` if the `node` option is enabled, `false` otherwise200 */159 readonly argv0?: string;201 readonly ipc?: Unless<IsSync, boolean>;202203 /**162 Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.204 Specify the kind of serialization used for sending messages between subprocesses when using the `ipc` option.205164 @default current user identifier206 @default 'advanced'207 */166 readonly uid?: number;208 readonly serialization?: Unless<IsSync, 'json' | 'advanced'>;209210 /**169 Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.211 If `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.212171 @default current group identifier172 */173 readonly gid?: number;213 If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.214175 /**176 If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).215 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.216178 Uses [`/bin/sh`](https://en.wikipedia.org/wiki/Unix_shell) on UNIX and [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.179180 We recommend against using this option.181182 @default false217 @default 'none'218 */184 readonly shell?: boolean | string | URL;219 readonly verbose?: FdGenericOption<'none' | 'short' | 'full'>;220221 /**187 If the subprocess outputs text, specifies its character encoding, either [`'utf8'`](https://en.wikipedia.org/wiki/UTF-8) or [`'utf16le'`](https://en.wikipedia.org/wiki/UTF-16).222 Setting this to `false` resolves the result's promise with the error instead of rejecting it.223189 If it outputs binary data instead, this should be either:190 - `'buffer'`: returns the binary output as an `Uint8Array`.191 - [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64), [`'base64url'`](https://en.wikipedia.org/wiki/Base64#URL_applications), [`'latin1'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings) or [`'ascii'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings): encodes the binary output as a string.192193 The output is available with `result.stdout`, `result.stderr` and `result.stdio`.194195 @default 'utf8'224 @default true225 */197 readonly encoding?: EncodingOption;226 readonly reject?: boolean;227228 /**229 If `timeout` is greater than `0`, the subprocess will be terminated if it runs for longer than that amount of milliseconds.230
3 unmodified lines
234 */235 readonly timeout?: number;236237 /**209 Largest amount of data allowed on `stdout`, `stderr` and `stdio`.238 You can abort the subprocess using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).239211 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.240 When `AbortController.abort()` is called, `result.isCanceled` becomes `true`.241213 @default 100_000_000214 */215 readonly maxBuffer?: FdGenericOption<number>;242 @example243 ```244 import {execa} from 'execa';245217 /**218 Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.246 const abortController = new AbortController();247 const subprocess = execa('node', [], {cancelSignal: abortController.signal});248220 This can be either a name (like `'SIGTERM'`) or a number (like `9`).249 setTimeout(() => {250 abortController.abort();251 }, 1000);252222 @default 'SIGTERM'253 try {254 await subprocess;255 } catch (error) {256 console.log(error.isTerminated); // true257 console.log(error.isCanceled); // true258 }259 ```260 */224 readonly killSignal?: string | number;261 readonly cancelSignal?: Unless<IsSync, AbortSignal>;262263 /**264 If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).265
1 unmodified line
267 */268 readonly forceKillAfterDelay?: Unless<IsSync, number | false>;269270 /**234 If `false`, escapes the command arguments on Windows.271 Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.272236 @default `true` if the `shell` option is `true`, `false` otherwise237 */238 readonly windowsVerbatimArguments?: boolean;273 This can be either a name (like `'SIGTERM'`) or a number (like `9`).274240 /**241 On Windows, do not create a new console window.242243 @default true275 @default 'SIGTERM'276 */245 readonly windowsHide?: boolean;277 readonly killSignal?: string | number;278279 /**248 If `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.280 Run the subprocess independently from the current process.281250 If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.251252 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.253254 @default 'none'282 @default false283 */256 readonly verbose?: FdGenericOption<'none' | 'short' | 'full'>;284 readonly detached?: Unless<IsSync, boolean>;285286 /**287 Kill the subprocess when the current process exits.288
1 unmodified line
290 */291 readonly cleanup?: Unless<IsSync, boolean>;292293 /**266 When `buffer` is `false`, the `result.stdout`, `result.stderr`, `result.all` and `result.stdio` properties are not set.294 Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.295268 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.269270 @default true296 @default current user identifier297 */272 readonly buffer?: FdGenericOption<boolean>;298 readonly uid?: number;299300 /**275 Add a `subprocess.all` stream and a `result.all` property. They contain the combined/interleaved output of the subprocess' `stdout` and `stderr`.301 Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.302277 @default false303 @default current group identifier304 */279 readonly all?: boolean;305 readonly gid?: number;306307 /**282 Enables exchanging messages with the subprocess using `subprocess.send(message)` and `subprocess.on('message', (message) => {})`.308 Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.309284 @default `true` if the `node` option is enabled, `false` otherwise310 @default file being executed311 */286 readonly ipc?: Unless<IsSync, boolean>;312 readonly argv0?: string;313314 /**289 Specify the kind of serialization used for sending messages between subprocesses when using the `ipc` option.315 On Windows, do not create a new console window.316291 @default 'advanced'317 @default true318 */293 readonly serialization?: Unless<IsSync, 'json' | 'advanced'>;319 readonly windowsHide?: boolean;320321 /**296 Run the subprocess independently from the current process.322 If `false`, escapes the command arguments on Windows.323298 @default false324 @default `true` if the `shell` option is `true`, `false` otherwise325 */300 readonly detached?: Unless<IsSync, boolean>;301302 /**303 You can abort the subprocess using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).304305 When `AbortController.abort()` is called, `result.isCanceled` becomes `true`.306307 @example308 ```309 import {execa} from 'execa';310311 const abortController = new AbortController();312 const subprocess = execa('node', [], {cancelSignal: abortController.signal});313314 setTimeout(() => {315 abortController.abort();316 }, 1000);317318 try {319 await subprocess;320 } catch (error) {321 console.log(error.isTerminated); // true322 console.log(error.isCanceled); // true323 }324 ```325 */326 readonly cancelSignal?: Unless<IsSync, AbortSignal>;326 readonly windowsVerbatimArguments?: boolean;327};328329/**330Subprocess options.
30 unmodified lines
modified:types/return/final-error.d.ts+2 added-2 removed
modified:types/return/result.d.ts+42 added-42 removed
8 unmodified lines
9 IsSync extends boolean = boolean,10 OptionsType extends CommonOptions = CommonOptions,11> {12 /**13 The file and arguments that were run.14 */15 command: string;1617 /**18 Same as `command` but escaped.19 */20 escapedCommand: string;2122 /**23 The numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.2425 This is `undefined` when the subprocess could not be spawned or was terminated by a signal.26 */27 exitCode?: number;2829 /**13 The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).1415 This is `undefined` if the `stdout` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.16
30 unmodified lines
47 */48 stdio: ResultStdioArray<OptionsType>;4950 /**68 Whether the subprocess failed to run.51 Results of the other subprocesses that were piped into this subprocess.5253 This array is initially empty and is populated each time the `subprocess.pipe()` method resolves.54 */70 failed: boolean;55 pipedFrom: Unless<IsSync, ExecaResult[], []>;5657 /**73 Whether the subprocess timed out due to the `timeout` option.58 The file and arguments that were run.59 */75 timedOut: boolean;60 command: string;6162 /**78 Whether the subprocess was terminated by a signal (like `SIGTERM`) sent by either:79 - The current process.80 - Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).63 Same as `command` but escaped.64 */82 isTerminated: boolean;65 escapedCommand: string;6667 /**85 The name of the signal (like `SIGTERM`) that terminated the subprocess, sent by either:86 - The current process.87 - Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).8889 If a signal terminated the subprocess, this property is defined and included in the error message. Otherwise it is `undefined`.68 The current directory in which the command was run.69 */91 signal?: string;70 cwd: string;7172 /**94 A human-friendly description of the signal that was used to terminate the subprocess.9596 If 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.73 Duration of the subprocess, in milliseconds.74 */98 signalDescription?: string;75 durationMs: number;7677 /**101 The current directory in which the command was run.78 Whether the subprocess failed to run.79 */103 cwd: string;80 failed: boolean;8182 /**106 Duration of the subprocess, in milliseconds.83 Whether the subprocess timed out due to the `timeout` option.84 */108 durationMs: number;85 timedOut: boolean;8687 /**88 Whether the subprocess was canceled using the `cancelSignal` option.89 */
4 unmodified lines
94 */95 isMaxBuffer: boolean;9697 /**121 Results of the other subprocesses that were piped into this subprocess.98 Whether the subprocess was terminated by a signal (like `SIGTERM`) sent by either:99 - The current process.100 - Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).101 */102 isTerminated: boolean;103123 This array is initially empty and is populated each time the `subprocess.pipe()` method resolves.104 /**105 The numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.106107 This is `undefined` when the subprocess could not be spawned or was terminated by a signal.108 */125 pipedFrom: Unless<IsSync, ExecaResult[], []>;109 exitCode?: number;110111 /**112 The name of the signal (like `SIGTERM`) that terminated the subprocess, sent by either:113 - The current process.114 - Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).115116 If a signal terminated the subprocess, this property is defined and included in the error message. Otherwise it is `undefined`.117 */118 signal?: string;119120 /**121 A human-friendly description of the signal that was used to terminate the subprocess.122123 If 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.124 */125 signalDescription?: string;126127 /**128 Error message when the subprocess failed to run.129 */130 message?: string;131
56 unmodified lines
modified:readme.md+184 added-184 removed
386 unmodified lines
387Just like `execa()`, this can [bind options](docs/execution.md#globalshared-options). It can also be [run synchronously](#execasyncfile-arguments-options) using `execaCommandSync()`.388389[More info.](docs/escaping.md#user-defined-input)390391### subprocess391### Subprocess392393The return value of all [asynchronous methods](#methods) is both:394- a `Promise` resolving or rejecting with a subprocess [`result`](#result).395- a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following methods and properties.396397[More info.](docs/execution.md#subprocess)398399#### subprocess\[Symbol.asyncIterator\]()400401_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)402403Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.404405[More info.](docs/lines.md#progressive-splitting)406407#### subprocess.iterable(readableOptions?)408409`readableOptions`: [`ReadableOptions`](#readableoptions)\410_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)411412Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.413414[More info.](docs/lines.md#progressive-splitting)415416#### subprocess.pipe(file, arguments?, options?)417418`file`: `string | URL`\419`arguments`: `string[]`\
160 unmodified lines
580Each array item is `null` if the corresponding [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option is set to [`'inherit'`](docs/output.md#terminal-output), [`'ignore'`](docs/output.md#ignore-output), [`Stream`](docs/streams.md#output) or [`integer`](docs/output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.581582[More info.](docs/streams.md#manual-streaming)583567#### subprocess\[Symbol.asyncIterator\]()568569_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)570571Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.572573[More info.](docs/lines.md#progressive-splitting)574575#### subprocess.iterable(readableOptions?)576577`readableOptions`: [`ReadableOptions`](#readableoptions)\578_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)579580Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.581582[More info.](docs/lines.md#progressive-splitting)583584#### subprocess.readable(readableOptions?)585586`readableOptions`: [`ReadableOptions`](#readableoptions)\587_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream
1 unmodified line
589Converts the subprocess to a readable stream.590591[More info.](docs/streams.md#converting-a-subprocess-to-a-stream)592593#### subprocess.writable(writableOptions?)594595`writableOptions`: [`WritableOptions`](#writableoptions)\596_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream597598Converts the subprocess to a writable stream.599600[More info.](docs/streams.md#converting-a-subprocess-to-a-stream)601602#### subprocess.duplex(duplexOptions?)603604`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\605_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream606607Converts the subprocess to a duplex stream.608609[More info.](docs/streams.md#converting-a-subprocess-to-a-stream)610593##### readableOptions594595Type: `object`596
29 unmodified lines
626If both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.627628[More info.](docs/lines.md#iterable)629630#### subprocess.writable(writableOptions?)631632`writableOptions`: [`WritableOptions`](#writableoptions)\633_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream634635Converts the subprocess to a writable stream.636637[More info.](docs/streams.md#converting-a-subprocess-to-a-stream)638639##### writableOptions640641Type: `object`642
5 unmodified lines
648Which [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.649650[More info.](docs/streams.md#different-file-descriptor)651652#### subprocess.duplex(duplexOptions?)653654`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\655_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream656657Converts the subprocess to a duplex stream.658659[More info.](docs/streams.md#converting-a-subprocess-to-a-stream)660661### Result662663Type: `object`664665[Result](docs/execution.md#result) of a subprocess execution.666667When the subprocess [fails](docs/errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.668669#### result.command670671Type: `string`672673The file and [arguments](docs/input.md#command-arguments) that were run.674675[More info.](docs/debugging.md#command)676677#### result.escapedCommand678679Type: `string`680681Same as [`command`](#resultcommand) but escaped.682683[More info.](docs/debugging.md#command)684685#### result.cwd686687Type: `string`688689The [current directory](#optionscwd) in which the command was run.690691[More info.](docs/environment.md#current-directory)692693#### result.durationMs694695Type: `number`696697Duration of the subprocess, in milliseconds.698699[More info.](docs/debugging.md#duration)700669#### result.stdout670671Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`672
42 unmodified lines
715Items are arrays when their corresponding `stdio` option is a [transform in object mode](docs/transform.md#object-mode).716717[More info.](docs/output.md#additional-file-descriptors)718719#### result.pipedFrom720721Type: [`Array<Result | ExecaError>`](#result)722723[Results](#result) of the other subprocesses that were [piped](#pipe-multiple-subprocesses) into this subprocess.724725This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.726727[More info.](docs/pipe.md#errors)728729#### result.command730731Type: `string`732733The file and [arguments](docs/input.md#command-arguments) that were run.734735[More info.](docs/debugging.md#command)736737#### result.escapedCommand738739Type: `string`740741Same as [`command`](#resultcommand) but escaped.742743[More info.](docs/debugging.md#command)744745#### result.cwd746747Type: `string`748749The [current directory](#optionscwd) in which the command was run.750751[More info.](docs/environment.md#current-directory)752753#### result.durationMs754755Type: `number`756757Duration of the subprocess, in milliseconds.758759[More info.](docs/debugging.md#duration)760761#### result.failed762763Type: `boolean`764
16 unmodified lines
781Whether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.782783[More info.](docs/termination.md#canceling)784785#### result.isMaxBuffer786787Type: `boolean`788789Whether the subprocess failed because its output was larger than the [`maxBuffer`](#optionsmaxbuffer) option.790791[More info.](docs/output.md#big-output)792793#### result.isTerminated794795Type: `boolean`796
2 unmodified lines
799- [Another process](docs/termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).800801[More info.](docs/termination.md#signal-name-and-description)802785#### result.isMaxBuffer786787Type: `boolean`788789Whether the subprocess failed because its output was larger than the [`maxBuffer`](#optionsmaxbuffer) option.790791[More info.](docs/output.md#big-output)792803#### result.exitCode804805Type: `number | undefined`806
24 unmodified lines
831If 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.832833[More info.](docs/termination.md#signal-name-and-description)834825#### result.pipedFrom826827Type: [`Array<Result | ExecaError>`](#result)828829[Results](#result) of the other subprocesses that were [piped](#pipe-multiple-subprocesses) into this subprocess.830831This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.832833[More info.](docs/pipe.md#errors)834835### ExecaError836### ExecaSyncError837838Type: `Error`
43 unmodified lines
882Type: `string | undefined`883884Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.885886### options886### Options887888Type: `object`889890This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).891892The following options [can specify different values](docs/output.md#stdoutstderr-specific-options) for [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr): [`verbose`](#optionsverbose), [`lines`](#optionslines), [`stripFinalNewline`](#optionsstripfinalnewline), [`buffer`](#optionsbuffer), [`maxBuffer`](#optionsmaxbuffer).893894#### options.reject895896Type: `boolean`\897Default: `true`898899Setting this to `false` resolves the [result's promise](#subprocess) with the [error](#execaerror) instead of rejecting it.900901[More info.](docs/errors.md#preventing-exceptions)902903#### options.shell904905Type: `boolean | string | URL`\906Default: `false`907908If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).909910Uses [`/bin/sh`](https://en.wikipedia.org/wiki/Unix_shell) on UNIX and [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.911912We [recommend against](docs/shell.md#avoiding-shells) using this option.913914[More info.](docs/shell.md)915916#### options.cwd917918Type: `string | URL`\919Default: `process.cwd()`920921Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.922923This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.924925[More info.](docs/environment.md#current-directory)926927#### options.env928929Type: `object`\930Default: [`process.env`](https://nodejs.org/api/process.html#processenv)931932[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).933934Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).935936[More info.](docs/input.md#environment-variables)937938#### options.extendEnv939940Type: `boolean`\941Default: `true`942943If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).944If `false`, only the `env` option is used, not `process.env`.945946[More info.](docs/input.md#environment-variables)947894#### options.preferLocal895896Type: `boolean`\897Default: `true` with [`$`](#file-arguments-options), `false` otherwise
41 unmodified lines
939Requires the [`node`](#optionsnode) option to be `true`.940941[More info.](docs/node.md#nodejs-version)942997#### options.verbose943#### options.shell944999Type: `'none' | 'short' | 'full'`\1000Default: `'none'`945Type: `boolean | string | URL`\946Default: `false`9471002If `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.948If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).9491004If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.950Uses [`/bin/sh`](https://en.wikipedia.org/wiki/Unix_shell) on UNIX and [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.9511006By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](docs/output.md#stdoutstderr-specific-options).952We [recommend against](docs/shell.md#avoiding-shells) using this option.9531008[More info.](docs/debugging.md#verbose-mode)954[More info.](docs/shell.md)9551010#### options.buffer956#### options.cwd957958Type: `string | URL`\959Default: `process.cwd()`960961Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.962963This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.964965[More info.](docs/environment.md#current-directory)966967#### options.env968969Type: `object`\970Default: [`process.env`](https://nodejs.org/api/process.html#processenv)971972[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).973974Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).975976[More info.](docs/input.md#environment-variables)977978#### options.extendEnv979980Type: `boolean`\981Default: `true`9821015When `buffer` is `false`, the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties are not set.983If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).984If `false`, only the `env` option is used, not `process.env`.9851017By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](docs/output.md#stdoutstderr-specific-options).986[More info.](docs/input.md#environment-variables)9871019[More info.](docs/output.md#low-memory)1020988#### options.input989990Type: `string | Uint8Array | stream.Readable`991
67 unmodified lines
1059Add a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.10601061[More info.](docs/output.md#interleaved-output)10621096#### options.lines10971098Type: `boolean`\1099Default: `false`11001101Set [`result.stdout`](#resultstdout), [`result.stderr`](#resultstdout), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) as arrays of strings, splitting the subprocess' output into lines.11021103This cannot be used if the [`encoding`](#optionsencoding) option is [binary](docs/binary.md#binary-output).11041105By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](docs/output.md#stdoutstderr-specific-options).11061107[More info.](docs/lines.md#simple-splitting)11081063#### options.encoding10641065Type: `'utf8' | 'utf16le' | 'buffer' | 'hex' | 'base64' | 'base64url' | 'latin1' | 'ascii'`\1066Default: `'utf8'`
7 unmodified lines
1074The output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).10751076[More info.](docs/binary.md)10771078#### options.lines10791080Type: `boolean`\1081Default: `false`10821083Set [`result.stdout`](#resultstdout), [`result.stderr`](#resultstdout), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) as arrays of strings, splitting the subprocess' output into lines.10841085This cannot be used if the [`encoding`](#optionsencoding) option is [binary](docs/binary.md#binary-output).10861087By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](docs/output.md#stdoutstderr-specific-options).10881089[More info.](docs/lines.md#simple-splitting)10901091#### options.stripFinalNewline10921093Type: `boolean`\1094Default: `true`
16 unmodified lines
1111By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](docs/output.md#stdoutstderr-specific-options).11121113[More info.](docs/output.md#big-output)11141115#### options.buffer11161117Type: `boolean`\1118Default: `true`11191120When `buffer` is `false`, the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties are not set.11211122By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](docs/output.md#stdoutstderr-specific-options).11231124[More info.](docs/output.md#low-memory)11251126#### options.ipc11271128Type: `boolean`\1129Default: `true` if the [`node`](#optionsnode) option is enabled, `false` otherwise
10 unmodified lines
1140Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.11411142[More info.](docs/ipc.md#message-type)11431166#### options.detached1144#### options.verbose11451168Type: `boolean`\1169Default: `false`1146Type: `'none' | 'short' | 'full'`\1147Default: `'none'`11481171Run the subprocess independently from the current process.1149If `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.11501173[More info.](docs/environment.md#background-subprocess)1151If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.11521175#### options.cleanup1153By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](docs/output.md#stdoutstderr-specific-options).11541155[More info.](docs/debugging.md#verbose-mode)11561157#### options.reject11581159Type: `boolean`\1160Default: `true`11611180Kill the subprocess when the current process exits.1162Setting this to `false` resolves the [result's promise](#subprocess) with the [error](#execaerror) instead of rejecting it.11631182[More info.](docs/termination.md#current-process-exit)1164[More info.](docs/errors.md#preventing-exceptions)11651166#### options.timeout11671168Type: `number`\
34 unmodified lines
1203This can be either a name (like [`'SIGTERM'`](docs/termination.md#sigterm)) or a number (like `9`).12041205[More info.](docs/termination.md#default-signal)12061225#### options.argv01207#### options.detached12081227Type: `string`\1228Default: file being executed1209Type: `boolean`\1210Default: `false`12111230Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.1212Run the subprocess independently from the current process.12131214[More info.](docs/environment.md#background-subprocess)12151216#### options.cleanup12171218Type: `boolean`\1219Default: `true`12201221Kill the subprocess when the current process exits.12221223[More info.](docs/termination.md#current-process-exit)12241225#### options.uid12261227Type: `number`\1228Default: current user identifier
10 unmodified lines
1239Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.12401241[More info.](docs/windows.md#uid-and-gid)12421250#### options.windowsVerbatimArguments1243#### options.argv012441252Type: `boolean`\1253Default: `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwise1245Type: `string`\1246Default: file being executed12471255If `false`, escapes the command arguments on Windows.1248Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.12491257[More info.](docs/windows.md#cmdexe-escaping)12581250#### options.windowsHide12511252Type: `boolean`\1253Default: `true`
1 unmodified line
1255On Windows, do not create a new console window.12561257[More info.](docs/windows.md#console-window)12581259#### options.windowsVerbatimArguments12601261Type: `boolean`\1262Default: `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwise12631264If `false`, escapes the command arguments on Windows.12651266[More info.](docs/windows.md#cmdexe-escaping)12671268### Transform options12691270A transform or an [array of transforms](docs/transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.1271
56 unmodified lines