Skip to content
Myr

Do not mutate process promise (#328)

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 deb4988 · Browse files · 1 file+17 added−12 removed
This commit

State

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

Diff stats

1 file+17 added−12 removed

  • other:+17 added−12 removed

1 file+17 added−12 removed

modified:index.js+17 added-12 removed
114 unmodified lines
115 cleanup(timeoutId, removeExitHandler);116 });117118 const handlePromise = async () => {119 const [result, stdout, stderr, all] = await getSpawnedResult(spawned, parsed.options, processDone);120 result.stdout = handleOutput(parsed.options, stdout);121 result.stderr = handleOutput(parsed.options, stderr);122 result.all = handleOutput(parsed.options, all);119 const [{error, code, signal}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);120 const stdout = handleOutput(parsed.options, stdoutResult);121 const stderr = handleOutput(parsed.options, stderrResult);122 const all = handleOutput(parsed.options, allResult);123124 if (result.error || result.code !== 0 || result.signal !== null) {125 const error = makeError({126 ...result,124 if (error || code !== 0 || signal !== null) {125 const returnedError = makeError({126 error,127 code,128 signal,129 stdout,130 stderr,131 all,132 command,133 parsed,134 timedOut: context.timedOut,135 isCanceled: context.isCanceled,136 killed: spawned.killed137 });138139 if (!parsed.options.reject) {135 return error;140 return returnedError;141 }142138 throw error;143 throw returnedError;144 }145146 return {147 command,148 exitCode: 0,149 exitCodeName: 'SUCCESS',145 stdout: result.stdout,146 stderr: result.stderr,147 all: result.all,150 stdout,151 stderr,152 all,153 failed: false,154 timedOut: false,155 isCanceled: false,156 killed: false
130 unmodified lines