Skip to content

Commit 157aefd

Browse files
committed
fix(): ensure all child spawned npm process exit when the parent process ends. fixes #1544
1 parent 951fbc8 commit 157aefd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/cli.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ Cli.runWithNpmScripts = function runWithNpmScripts(argv, taskInstance, rawCliArg
312312
return Cli.runNpmHook(scripts[afterHook]);
313313
}
314314
});
315-
}
315+
};
316316

317317
Cli.runNpmHook = function runNpmHook(hook) {
318318
var cmd = 'npm';
@@ -347,9 +347,14 @@ Cli.runNpmHook = function runNpmHook(hook) {
347347
}
348348
return q.resolve();
349349
});
350+
351+
// If this process ends ensure that we killed the spawned child
352+
process.on('exit', function() {
353+
spawned.kill();
354+
});
350355

351356
return q.promise;
352-
}
357+
};
353358

354359
Cli.loadNpmScripts = function loadNpmScripts() {
355360
var fileName = 'package.json';

0 commit comments

Comments
 (0)