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

Commit 5d932c9

Browse files
EnzoMartinKent C. Dodds
authored and
Kent C. Dodds
committed
fix(kill): Add all kill signals
- Adds the 4 main kill signals that NodeJS handles - Add tests for kill signals, update test description
1 parent e847b18 commit 5d932c9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ function crossEnv(args) {
99
if (command) {
1010
const proc = spawn(command, commandArgs, {stdio: 'inherit', env});
1111
process.on('SIGTERM', () => proc.kill('SIGTERM'));
12+
process.on('SIGINT', () => proc.kill('SIGINT'));
13+
process.on('SIGBREAK', () => proc.kill('SIGBREAK'));
14+
process.on('SIGHUP', () => proc.kill('SIGHUP'));
1215
proc.on('exit', process.exit);
1316
return proc;
1417
}

src/index.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,19 @@ describe(`cross-env`, () => {
7171
expect(proxied['cross-spawn'].spawn).to.have.not.been.called;
7272
});
7373

74-
it(`should propage SIGTERM signal`, () => {
74+
it(`should propagate kill signals`, () => {
7575
testEnvSetting({
7676
FOO_ENV: 'foo=bar'
7777
}, 'FOO_ENV="foo=bar"');
7878

7979
process.emit('SIGTERM');
80+
process.emit('SIGINT');
81+
process.emit('SIGHUP');
82+
process.emit('SIGBREAK');
8083
expect(spawned.kill).to.have.been.calledWith('SIGTERM');
84+
expect(spawned.kill).to.have.been.calledWith('SIGINT');
85+
expect(spawned.kill).to.have.been.calledWith('SIGHUP');
86+
expect(spawned.kill).to.have.been.calledWith('SIGBREAK');
8187
});
8288

8389
function testEnvSetting(expected, ...envSettings) {

0 commit comments

Comments
 (0)