Skip to content

Commit

Permalink
Merge pull request #91 from carnun/master
Browse files Browse the repository at this point in the history
Change kill signal and add unit test
  • Loading branch information
Gil Amran committed May 19, 2020
2 parents 10554b2 + 2de5bc8 commit 81a2602
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/killer.js
Expand Up @@ -21,10 +21,10 @@ module.exports = function kill(child) {
} else {
if (hasPS) {
psTree(child.pid, function(err, kids) {
spawn('kill', ['-s', KILL_SIGNAL, child.pid].concat( kids.map(p => p.PID) )).on('close', resolve);
spawn('kill', ['-' + KILL_SIGNAL, child.pid].concat( kids.map(p => p.PID) )).on('close', resolve);
});
} else {
exec('kill -s ' + KILL_SIGNAL + ' ' + child.pid, resolve);
exec('kill -' + KILL_SIGNAL + ' ' + child.pid, resolve);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "tsc-watch",
"version": "4.2.6",
"version": "4.2.7",
"description": "The TypeScript compiler with onSuccess command",
"scripts": {
"test": "mocha test/**/*.js"
Expand Down
1 change: 0 additions & 1 deletion test/client.it.js
Expand Up @@ -3,7 +3,6 @@ const sinon = require('sinon');
const mochaEventually = require('mocha-eventually');
const eventually = fn => mochaEventually(fn, 8000, 50);
const TscWatchClient = require('../lib/client');
const { driver: tscWatchDriver } = require('./driver.js');

describe('Client Events', () => {
let watchClient;
Expand Down
23 changes: 23 additions & 0 deletions test/runner.it.js
@@ -0,0 +1,23 @@
const { expect } = require('chai');
const runner = require('../lib/runner');

describe.only('Runner', () => {
it('Should start a long running process and kill it before it finishes', (done) => {
const kill = runner('sleep 10')
setTimeout(function() {
kill().then(function(result) {
expect(result).to.deep.equal([0,null])
done()
})
}, 1)
})
it('Should start a short running process and not kill it before it finishes', (done) => {
const kill = runner('echo')
setTimeout(function() {
kill().then(function(result) {
expect(result).to.deep.equal([1,0])
done()
})
}, 5)
})
})

0 comments on commit 81a2602

Please sign in to comment.