Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Commit

Permalink
fix(kill): Add all kill signals
Browse files Browse the repository at this point in the history
- Adds the 4 main kill signals that NodeJS handles
- Add tests for kill signals, update test description
  • Loading branch information
EnzoMartin authored and Kent C. Dodds committed Oct 8, 2016
1 parent e847b18 commit 5d932c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ function crossEnv(args) {
if (command) {
const proc = spawn(command, commandArgs, {stdio: 'inherit', env});
process.on('SIGTERM', () => proc.kill('SIGTERM'));
process.on('SIGINT', () => proc.kill('SIGINT'));
process.on('SIGBREAK', () => proc.kill('SIGBREAK'));
process.on('SIGHUP', () => proc.kill('SIGHUP'));
proc.on('exit', process.exit);
return proc;
}
Expand Down
8 changes: 7 additions & 1 deletion src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,19 @@ describe(`cross-env`, () => {
expect(proxied['cross-spawn'].spawn).to.have.not.been.called;
});

it(`should propage SIGTERM signal`, () => {
it(`should propagate kill signals`, () => {
testEnvSetting({
FOO_ENV: 'foo=bar'
}, 'FOO_ENV="foo=bar"');

process.emit('SIGTERM');
process.emit('SIGINT');
process.emit('SIGHUP');
process.emit('SIGBREAK');
expect(spawned.kill).to.have.been.calledWith('SIGTERM');
expect(spawned.kill).to.have.been.calledWith('SIGINT');
expect(spawned.kill).to.have.been.calledWith('SIGHUP');
expect(spawned.kill).to.have.been.calledWith('SIGBREAK');
});

function testEnvSetting(expected, ...envSettings) {
Expand Down

0 comments on commit 5d932c9

Please sign in to comment.