Skip to content

Commit

Permalink
triggering sigint on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dsych committed Jul 20, 2017
1 parent 1c95d1d commit 9e80863
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/prompt.js
Expand Up @@ -92,6 +92,16 @@ prompt.start = function (options) {
stdout.write('\n');
process.exit(1);
});
} else {
// listen for the "Ctrl+C" key combination and trigger process event.
// See https://stackoverflow.com/questions/10021373/what-is-the-windows-equivalent-of-process-onsigint-in-node-js
stdin.on('keypress', function(char, key) {
if (key && key.ctrl && key.name == 'c') {
stdout.write('\n');
process.emit("SIGINT");
process.exit(1);
}
});
}

prompt.emit('start');
Expand Down

0 comments on commit 9e80863

Please sign in to comment.