Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const nodeCustom = ['inspect', 'inspect-brk', 'no-warnings'];
const nodeString = ['require'];

const nodeDevBoolean = ['clear', 'dedupe', 'fork', 'notify', 'poll', 'respawn', 'vm'];
const nodeDevNumber = ['debounce', 'deps', 'interval'];
const nodeDevNumber = ['debounce', 'deps', 'interval', 'kill'];
const nodeDevString = ['graceful_ipc', 'ignore', 'timestamp'];

const alias = Object.assign({}, nodeAlias);
Expand Down
13 changes: 12 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = function (
graceful_ipc: gracefulIPC,
ignore,
interval,
kill,
notify: notifyEnabled,
poll: forcePolling,
respawn,
Expand Down Expand Up @@ -60,11 +61,21 @@ module.exports = function (

const watcher = filewatcher({ debounce, forcePolling, interval });
let isPaused = false;
let killTimer = 0;

// The child_process
let child;

watcher.on('change', file => {
if (isPaused) return;

if (typeof kill === 'number') {
killTimer = setTimeout(() => {
console.log(`Sending SIGKILL after timeout (${kill} sec)`);
child.kill('SIGKILL');
}, kill * 1000);
}

clearOutput();
notify('Restarting', `${file} has been modified`);
watcher.removeAll();
Expand All @@ -91,7 +102,7 @@ module.exports = function (
*/
function start() {
isPaused = false;

clearTimeout(killTimer);
const args = nodeArgs.slice();

args.push(`--require=${resolveMain(localPath('wrap'))}`);
Expand Down