Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 17, 2019
1 parent 487ba7c commit 05d2da7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function makeError(result, options) {
}

error.failed = true;
error.timedOut = Boolean(timedOut);
error.timedOut = timedOut;
error.isCanceled = isCanceled;
error.killed = killed && !timedOut;
// `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize
Expand Down Expand Up @@ -339,6 +339,7 @@ const execa = (file, args, options) => {
}

let timeoutId;
const context = {timedOut: false};
let isCanceled = false;

const cleanup = () => {
Expand All @@ -355,7 +356,7 @@ const execa = (file, args, options) => {
if (parsed.options.timeout > 0) {
timeoutId = setTimeout(() => {
timeoutId = undefined;
spawned.timedOut = true;
context.timedOut = true;
spawned.kill(parsed.options.killSignal);
}, parsed.options.timeout);
}
Expand Down Expand Up @@ -391,7 +392,7 @@ const execa = (file, args, options) => {
code: result.code,
command,
parsed,
timedOut: spawned.timedOut,
timedOut: context.timedOut,
isCanceled,
killed: spawned.killed
});
Expand Down

0 comments on commit 05d2da7

Please sign in to comment.