Skip to content
Myr

Re-order return value properties (#801)

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

authored by ehmicky · committed by GitHub · parent 3bd96ba · Browse files · 4 files+92 added−49 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+92 added−49 removed

  • tests:+41 added−0 removed
  • other:+51 added−49 removed

4 files+92 added−49 removed

modified:lib/error.js+9 added-7 removed
modified:test/error.js+41 added
10 unmodified lines
11setFixtureDir();1213const TIMEOUT_REGEXP = /timed out after/;1415test('Return value properties are not missing and are ordered', async t => {16 const result = await execa('empty.js', {...fullStdio, all: true});17 t.deepEqual(Reflect.ownKeys(result), [18 'command',19 'escapedCommand',20 'failed',21 'timedOut',22 'isCanceled',23 'isTerminated',24 'exitCode',25 'stdout',26 'stderr',27 'all',28 'stdio',29 ]);30});3132test('Error properties are not missing and are ordered', async t => {33 const error = await t.throwsAsync(execa('fail.js', {...fullStdio, all: true}));34 t.deepEqual(Reflect.ownKeys(error), [35 'stack',36 'message',37 'originalMessage',38 'shortMessage',39 'command',40 'escapedCommand',41 'cwd',42 'failed',43 'timedOut',44 'isCanceled',45 'isTerminated',46 'exitCode',47 'signal',48 'signalDescription',49 'stdout',50 'stderr',51 'all',52 'stdio',53 ]);54});5556const testEmptyErrorStdio = async (t, execaMethod) => {57 const {failed, stdout, stderr, stdio} = await execaMethod('fail.js', {reject: false});58 t.true(failed);59 t.is(stdout, '');
340 unmodified lines
modified:index.js+9 added-9 removed
208 unmodified lines
209210 return {211 command,212 escapedCommand,213 exitCode: 0,214 stdio,215 stdout: stdio[1],216 stderr: stdio[2],217 all,213 failed: false,214 timedOut: false,215 isCanceled: false,216 isTerminated: false,217 exitCode: 0,218 stdout: stdio[1],219 stderr: stdio[2],220 all,221 stdio,222 };223};224225export function execaSync(rawFile, rawArgs, rawOptions) {
50 unmodified lines
276277 return {278 command,279 escapedCommand,280 exitCode: 0,281 stdio,282 stdout: stdio[1],283 stderr: stdio[2],280 failed: false,281 timedOut: false,282 isCanceled: false,283 isTerminated: false,284 exitCode: 0,285 stdout: stdio[1],286 stderr: stdio[2],287 stdio,288 };289}290291const validateSyncOptions = ({ipc}) => {
69 unmodified lines
modified:readme.md+33 added-33 removed
360 unmodified lines
361362This is meant to be copied and pasted into a shell, for debugging purposes.363Since the escaping is fairly basic, this should not be executed directly as a process, including using [`execa()`](#execafile-arguments-options) or [`execaCommand()`](#execacommandcommand-options).364365#### exitCode365#### cwd366367Type: `number | undefined`367Type: `string`368369The numeric exit code of the process that was run.369The `cwd` of the command if provided in the [command options](#cwd-1). Otherwise it is `process.cwd()`.370371This is `undefined` when the process could not be spawned or was terminated by a [signal](#signal-1).372371#### stdout372373Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`374
28 unmodified lines
403The output of the process on [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [other file descriptors](#stdio-1).404405Items 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).406407#### message408409Type: `string`410411Error message when the child process failed to run. In addition to the [underlying error message](#originalMessage), it also contains some information related to why the child process errored.412413The child process [`stderr`](#stderr), [`stdout`](#stdout) and other [file descriptors' output](#stdio) are appended to the end, separated with newlines and not interleaved.414415#### shortMessage416417Type: `string`418419This is the same as the [`message` property](#message) except it does not include the child process [`stdout`](#stdout)/[`stderr`](#stderr)/[`stdio`](#stdio).420421#### originalMessage422423Type: `string | undefined`424425Original error message. This is the same as the `message` property excluding the child process [`stdout`](#stdout)/[`stderr`](#stderr)/[`stdio`](#stdio) and some additional information added by Execa.426427This is `undefined` unless the child process exited due to an `error` event or a timeout.428429#### failed430431Type: `boolean`432
18 unmodified lines
451Whether the process was terminated by a signal (like `SIGTERM`) sent by either:452- The current process.453- Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).454455#### exitCode456457Type: `number | undefined`458459The numeric exit code of the process that was run.460461This is `undefined` when the process could not be spawned or was terminated by a [signal](#signal-1).462463#### signal464465Type: `string | undefined`466
10 unmodified lines
477A human-friendly description of the signal that was used to terminate the process. For example, `Floating point arithmetic error`.478479If a signal terminated the process, 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.480453#### cwd454455Type: `string`456457The `cwd` of the command if provided in the [command options](#cwd-1). Otherwise it is `process.cwd()`.458459#### message460461Type: `string`462463Error message when the child process failed to run. In addition to the [underlying error message](#originalMessage), it also contains some information related to why the child process errored.464465The child process [`stderr`](#stderr), [`stdout`](#stdout) and other [file descriptors' output](#stdio) are appended to the end, separated with newlines and not interleaved.466467#### shortMessage468469Type: `string`470471This is the same as the [`message` property](#message) except it does not include the child process [`stdout`](#stdout)/[`stderr`](#stderr)/[`stdio`](#stdio).472473#### originalMessage474475Type: `string | undefined`476477Original error message. This is the same as the `message` property excluding the child process [`stdout`](#stdout)/[`stderr`](#stderr)/[`stdio`](#stdio) and some additional information added by Execa.478479This is `undefined` unless the child process exited due to an `error` event or a timeout.480481### options482483Type: `object`484
465 unmodified lines