diff --git a/index.d.ts b/index.d.ts index a6a1976cb..054c097d8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -194,6 +194,11 @@ declare namespace execa { } interface ExecaReturnBase { + /** + The command that was run. + */ + command: string; + /** The numeric exit code of the process that was run. */ @@ -219,16 +224,6 @@ declare namespace execa { */ failed: boolean; - /** - The signal that was used to terminate the process. - */ - signal?: string; - - /** - The command that was run. - */ - command: string; - /** Whether the process timed out. */ @@ -238,6 +233,11 @@ declare namespace execa { Whether the process was killed. */ killed: boolean; + + /** + The signal that was used to terminate the process. + */ + signal?: string; } interface ExecaSyncReturnValue diff --git a/index.test-d.ts b/index.test-d.ts index 4f9453660..a6c95f654 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -15,14 +15,14 @@ try { const unicornsResult = await execaPromise; expectType(unicornsResult.command); expectType(unicornsResult.code); - expectType(unicornsResult.failed); - expectType(unicornsResult.killed); - expectType(unicornsResult.signal); expectType(unicornsResult.stderr); expectType(unicornsResult.stdout); expectType(unicornsResult.all); + expectType(unicornsResult.failed); expectType(unicornsResult.timedOut); expectType(unicornsResult.isCanceled); + expectType(unicornsResult.killed); + expectType(unicornsResult.signal); } catch (error) { const execaError: ExecaError = error; @@ -36,14 +36,14 @@ try { const unicornsResult = execa.sync('unicorns'); expectType(unicornsResult.command); expectType(unicornsResult.code); - expectType(unicornsResult.failed); - expectType(unicornsResult.killed); - expectType(unicornsResult.signal); expectType(unicornsResult.stderr); expectType(unicornsResult.stdout); - expectType(unicornsResult.timedOut); expectError(unicornsResult.all); + expectType(unicornsResult.failed); + expectType(unicornsResult.timedOut); expectError(unicornsResult.isCanceled); + expectType(unicornsResult.killed); + expectType(unicornsResult.signal); } catch (error) { const execaError: ExecaSyncError = error; diff --git a/readme.md b/readme.md index f7be04537..d735f0143 100644 --- a/readme.md +++ b/readme.md @@ -60,18 +60,22 @@ const execa = require('execa'); console.log(error); /* { - message: 'spawn wrong command ENOENT', + message: 'Command failed with exit code 2 (ENOENT): wrong command spawn wrong ENOENT', errno: 'ENOENT', - code: 'ENOENT', - syscall: 'spawn wrong command', - path: 'wrong command', - killed: false, + code: 2, + syscall: 'spawn wrong', + path: 'wrong', + spawnargs: ['command'], + command: 'wrong command', + exitCode: 2, + exitCodeName: 'ENOENT', stdout: '', stderr: '', + all: '', failed: true, - signal: null, - cmd: 'wrong command', - timedOut: false + timedOut: false, + isCanceled: false, + killed: false } */ } @@ -96,11 +100,20 @@ try { console.log(error); /* { - message: 'spawnSync wrong command ENOENT', + message: 'Command failed with exit code 2 (ENOENT): wrong command spawnSync wrong ENOENT', errno: 'ENOENT', - code: 'ENOENT', - syscall: 'spawnSync wrong command', - path: 'wrong command', + code: 2, + syscall: 'spawnSync wrong', + path: 'wrong', + spawnargs: ['command'], + command: 'wrong command', + exitCode: 2, + exitCodeName: 'ENOENT', + stdout: null, + stderr: null, + failed: true, + timedOut: false, + isCanceled: false } */ } @@ -147,6 +160,12 @@ Type: `object` Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance. +#### command + +Type: `string` + +The command that was run. + #### exitCode Type: `number` @@ -177,12 +196,6 @@ Type: `string | Buffer` The output of the process on both stdout and stderr. `undefined` if `execa.sync()` was used. -#### command - -Type: `string` - -The command that was run. - #### failed Type: `boolean` @@ -195,17 +208,17 @@ Type: `boolean` Whether the process timed out. -#### killed +#### isCanceled Type: `boolean` -Whether the process was killed. +Whether the process was canceled. -#### isCanceled +#### killed Type: `boolean` -Whether the process was canceled. +Whether the process was killed. #### signal