Skip to content

Commit 756fa65

Browse files
committed
Fix inconsistent options.noHandleSIGINT for windows
1 parent 8d5495c commit 756fa65

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

lib/prompt.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,24 @@ prompt.start = function (options) {
8686
prompt.delimiter = options.delimiter || prompt.delimiter;
8787
prompt.colors = options.colors || prompt.colors;
8888

89-
if (process.platform !== 'win32' && !options.noHandleSIGINT) {
90-
// windows falls apart trying to deal with SIGINT
91-
process.on('SIGINT', function () {
92-
stdout.write('\n');
93-
process.exit(1);
94-
});
95-
} else {
96-
// listen for the "Ctrl+C" key combination and trigger process event.
97-
// See https://stackoverflow.com/questions/10021373/what-is-the-windows-equivalent-of-process-onsigint-in-node-js
98-
stdin.on('keypress', function(char, key) {
99-
if (key && key.ctrl && key.name == 'c') {
89+
if (!options.noHandleSIGINT) {
90+
if (process.platform !== 'win32') {
91+
// windows falls apart trying to deal with SIGINT
92+
process.on('SIGINT', function () {
10093
stdout.write('\n');
101-
process.emit("SIGINT");
10294
process.exit(1);
103-
}
104-
});
95+
});
96+
} else {
97+
// listen for the "Ctrl+C" key combination and trigger process event.
98+
// See https://stackoverflow.com/questions/10021373/what-is-the-windows-equivalent-of-process-onsigint-in-node-js
99+
stdin.on('keypress', function(char, key) {
100+
if (key && key.ctrl && key.name == 'c') {
101+
stdout.write('\n');
102+
process.emit("SIGINT");
103+
process.exit(1);
104+
}
105+
});
106+
}
105107
}
106108

107109
prompt.emit('start');

0 commit comments

Comments
 (0)