Skip to content

Commit

Permalink
fix(): ensure all child spawned npm process exit when the parent proc…
Browse files Browse the repository at this point in the history
…ess ends. fixes #1544
  • Loading branch information
jthoms1 committed Oct 14, 2016
1 parent 951fbc8 commit 157aefd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Cli.runWithNpmScripts = function runWithNpmScripts(argv, taskInstance, rawCliArg
return Cli.runNpmHook(scripts[afterHook]);
}
});
}
};

Cli.runNpmHook = function runNpmHook(hook) {
var cmd = 'npm';
Expand Down Expand Up @@ -347,9 +347,14 @@ Cli.runNpmHook = function runNpmHook(hook) {
}
return q.resolve();
});

// If this process ends ensure that we killed the spawned child
process.on('exit', function() {
spawned.kill();
});

return q.promise;
}
};

Cli.loadNpmScripts = function loadNpmScripts() {
var fileName = 'package.json';
Expand Down

0 comments on commit 157aefd

Please sign in to comment.