From ea5a7b90299ef2a78d93ede945d7a29b55660380 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Mon, 13 May 2019 14:15:38 +0200 Subject: [PATCH] Reorder properties of results and errors --- index.js | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index dd14df7607..5719da234b 100644 --- a/index.js +++ b/index.js @@ -181,24 +181,25 @@ function makeError(result, options) { error = new Error(message); } - error.code = exitCode || exitCodeName; + error.command = joinedCommand; error.exitCode = exitCode; error.exitCodeName = exitCodeName; + error.code = exitCode || exitCodeName; error.stdout = stdout; error.stderr = stderr; - error.failed = true; - // `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize - // it to `undefined` - error.signal = signal || undefined; - error.command = joinedCommand; - error.timedOut = timedOut; - error.isCanceled = isCanceled; - error.killed = killed && !timedOut; if ('all' in result) { error.all = result.all; } + error.failed = true; + error.timedOut = timedOut; + error.isCanceled = isCanceled; + error.killed = killed && !timedOut; + // `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize + // it to `undefined` + error.signal = signal || undefined; + return error; } @@ -372,17 +373,17 @@ const execa = (command, args, options) => { } return { + command: joinedCommand, + exitCode: 0, + exitCodeName: 'SUCCESS', + code: 0, stdout: handleOutput(parsed.options, result.stdout), stderr: handleOutput(parsed.options, result.stderr), all: handleOutput(parsed.options, result.all), - code: 0, - exitCode: 0, - exitCodeName: 'SUCCESS', failed: false, - killed: false, - command: joinedCommand, timedOut: false, - isCanceled: false + isCanceled: false, + killed: false }; }; @@ -442,15 +443,15 @@ module.exports.sync = (command, args, options) => { } return { - stdout: handleOutput(parsed.options, result.stdout), - stderr: handleOutput(parsed.options, result.stderr), - code: 0, + command: joinedCommand, exitCode: 0, exitCodeName: 'SUCCESS', + code: 0, + stdout: handleOutput(parsed.options, result.stdout), + stderr: handleOutput(parsed.options, result.stderr), failed: false, - killed: false, - command: joinedCommand, timedOut: false, - isCanceled: false + isCanceled: false, + killed: false }; };