Skip to content

Commit

Permalink
Rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 3, 2019
1 parent 152e4d6 commit 214e6bf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.js
Expand Up @@ -213,21 +213,21 @@ function joinCommand(file, args = []) {
return [file, ...args].join(' ');
}

function kill(originalKill, signal = 'SIGTERM', options = {}) {
const killResult = originalKill(signal);
setKillTimeout(originalKill, signal, options, killResult);
function spawnedKill(kill, signal = 'SIGTERM', options = {}) {
const killResult = kill(signal);
setKillTimeout(kill, signal, options, killResult);
return killResult;
}

function setKillTimeout(originalKill, signal, options, killResult) {
function setKillTimeout(kill, signal, options, killResult) {
if (!shouldForceKill(signal, options, killResult)) {
return;
}

const forceKillAfter = Number.isInteger(options.forceKillAfter) ?
options.forceKillAfter :
5000;
setTimeout(() => originalKill('SIGKILL'), forceKillAfter).unref();
setTimeout(() => kill('SIGKILL'), forceKillAfter).unref();
}

function shouldForceKill(signal, options, killResult) {
Expand Down Expand Up @@ -256,8 +256,8 @@ const execa = (file, args, options) => {
}));
}

const originalKill = spawned.kill.bind(spawned);
spawned.kill = kill.bind(null, originalKill);
const kill = spawned.kill.bind(spawned);
spawned.kill = spawnedKill.bind(null, kill);

// #115
let removeExitHandler;
Expand Down

0 comments on commit 214e6bf

Please sign in to comment.