Skip to content
Myr

Reorder properties of results and errors (#241)

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

authored by ehmicky · committed by Sindre Sorhus · parent 0d39fdf · Browse files · 4 files+74 added−60 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+74 added−60 removed

  • other:+74 added−60 removed

4 files+74 added−60 removed

modified:index.d.ts+10 added-10 removed
193 unmodified lines
194 }195196 interface ExecaReturnBase<StdoutStderrType> {197 /**198 The command that was run.199 */200 command: string;201202 /**203 The numeric exit code of the process that was run.204 */205 exitCode: number;206
17 unmodified lines
224 */225 failed: boolean;226227 /**223 The signal that was used to terminate the process.224 */225 signal?: string;226227 /**228 The command that was run.229 */230 command: string;231232 /**228 Whether the process timed out.229 */230 timedOut: boolean;231232 /**233 Whether the process was killed.234 */235 killed: boolean;236237 /**238 The signal that was used to terminate the process.239 */240 signal?: string;241 }242243 interface ExecaSyncReturnValue<StdoutErrorType = string>244 extends ExecaReturnBase<StdoutErrorType> {
138 unmodified lines
modified:index.js+22 added-21 removed
179 unmodified lines
180 } else {181 error = new Error(message);182 }183184 error.code = exitCode || exitCodeName;184 error.command = joinedCommand;185 error.exitCode = exitCode;186 error.exitCodeName = exitCodeName;187 error.code = exitCode || exitCodeName;188 error.stdout = stdout;189 error.stderr = stderr;189 error.failed = true;190 // `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize191 // it to `undefined`192 error.signal = signal || undefined;193 error.command = joinedCommand;194 error.timedOut = timedOut;195 error.isCanceled = isCanceled;196 error.killed = killed && !timedOut;190191 if ('all' in result) {192 error.all = result.all;193 }194195 error.failed = true;196 error.timedOut = timedOut;197 error.isCanceled = isCanceled;198 error.killed = killed && !timedOut;199 // `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize200 // it to `undefined`201 error.signal = signal || undefined;202203 return error;204}205206function getCode({error = {}}, code) {
165 unmodified lines
372 throw error;373 }374375 return {376 command: joinedCommand,377 exitCode: 0,378 exitCodeName: 'SUCCESS',379 code: 0,380 stdout: result.stdout,381 stderr: result.stderr,382 all: result.all,378 code: 0,379 exitCode: 0,380 exitCodeName: 'SUCCESS',383 failed: false,382 killed: false,383 command: joinedCommand,384 timedOut: false,385 isCanceled: false385 isCanceled: false,386 killed: false387 };388 };389390 // TODO: Use native "finally" syntax when targeting Node.js 10
53 unmodified lines
444 throw error;445 }446447 return {447 stdout: result.stdout,448 stderr: result.stderr,449 code: 0,448 command: joinedCommand,449 exitCode: 0,450 exitCodeName: 'SUCCESS',451 code: 0,452 stdout: result.stdout,453 stderr: result.stderr,454 failed: false,453 killed: false,454 command: joinedCommand,455 timedOut: false,456 isCanceled: false456 isCanceled: false,457 killed: false458 };459};
modified:index.test-d.ts+7 added-7 removed
modified:readme.md+35 added-22 removed
58 unmodified lines
59 } catch (error) {60 console.log(error);61 /*62 {63 message: 'spawn wrong command ENOENT',63 message: 'Command failed with exit code 2 (ENOENT): wrong command spawn wrong ENOENT',64 errno: 'ENOENT',65 code: 'ENOENT',66 syscall: 'spawn wrong command',67 path: 'wrong command',68 killed: false,65 code: 2,66 syscall: 'spawn wrong',67 path: 'wrong',68 spawnargs: ['command'],69 command: 'wrong command',70 exitCode: 2,71 exitCodeName: 'ENOENT',72 stdout: '',73 stderr: '',74 all: '',75 failed: true,72 signal: null,73 cmd: 'wrong command',74 timedOut: false76 timedOut: false,77 isCanceled: false,78 killed: false79 }80 */81 }82
16 unmodified lines
99} catch (error) {100 console.log(error);101 /*102 {99 message: 'spawnSync wrong command ENOENT',103 message: 'Command failed with exit code 2 (ENOENT): wrong command spawnSync wrong ENOENT',104 errno: 'ENOENT',101 code: 'ENOENT',102 syscall: 'spawnSync wrong command',103 path: 'wrong command',105 code: 2,106 syscall: 'spawnSync wrong',107 path: 'wrong',108 spawnargs: ['command'],109 command: 'wrong command',110 exitCode: 2,111 exitCodeName: 'ENOENT',112 stdout: null,113 stderr: null,114 failed: true,115 timedOut: false,116 isCanceled: false117 }118 */119}120```
38 unmodified lines
159Type: `object`160161Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.162163#### command164165Type: `string`166167The command that was run.168169#### exitCode170171Type: `number`172
22 unmodified lines
195Type: `string | Buffer`196197The output of the process on both stdout and stderr. `undefined` if `execa.sync()` was used.198180#### command181182Type: `string`183184The command that was run.185199#### failed200201Type: `boolean`202
4 unmodified lines
207Type: `boolean`208209Whether the process timed out.210198#### killed211#### isCanceled212213Type: `boolean`214202Whether the process was killed.215Whether the process was canceled.216204#### isCanceled217#### killed218219Type: `boolean`220208Whether the process was canceled.221Whether the process was killed.222223#### signal224225Type: `string | undefined`
204 unmodified lines