From 3d2622c87b574935ba77d5d5161aca6516fa41a8 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Mon, 17 Jun 2019 10:00:00 +0200 Subject: [PATCH] Refactoring --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index ee518c069e..e4d7f868e9 100644 --- a/index.js +++ b/index.js @@ -285,10 +285,10 @@ function getForceKillAfterTimeout({forceKillAfterTimeout = true}) { return forceKillAfterTimeout; } -function handleSpawned(spawned) { +function handleSpawned(spawned, context) { return new Promise((resolve, reject) => { spawned.on('exit', (code, signal) => { - if (spawned.timedOut) { + if (context.timedOut) { return reject(Object.assign(new Error('Timed out'), {code, signal})); } @@ -362,7 +362,7 @@ const execa = (file, args, options) => { } // TODO: Use native "finally" syntax when targeting Node.js 10 - const processDone = pFinally(handleSpawned(spawned), cleanup); + const processDone = pFinally(handleSpawned(spawned, context), cleanup); const handlePromise = async () => { const stdoutPromise = getStreamPromise(spawned.stdout, {encoding, buffer, maxBuffer});