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 c992a14 commit a25ab53
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 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(() => forceKill(originalKill), forceKillAfter).unref();
setTimeout(() => forceKill(kill), forceKillAfter).unref();
}

function shouldForceKill(signal, options, killResult) {
Expand All @@ -238,9 +238,9 @@ function shouldForceKill(signal, options, killResult) {
killResult;
}

function forceKill(originalKill) {
function forceKill(kill) {
try {
originalKill('SIGKILL');
kill('SIGKILL');
} catch (_) {}
}

Expand All @@ -262,8 +262,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 a25ab53

Please sign in to comment.