Skip to content

Commit 617eed2

Browse files
committed
refs #57: [Windows] fixes EOF issue in interactive mode.
Signed-off-by: Eric Wang <[email protected]>
1 parent 62d8a8c commit 617eed2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/helper.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,19 @@ h.readStdin = function(cb) {
165165
var stdin = process.stdin;
166166
var bufs = [];
167167

168+
console.log('NOTE: to finish the input, press ' +
169+
(this.isWindows() ? '<Ctrl-D> and <Return>' : '<Ctrl-D>'));
170+
168171
stdin.on('readable', function() {
169172
var data = stdin.read();
170-
if (data) bufs.push(data);
173+
if (data) {
174+
// windows doesn't treat ctrl-D as EOF
175+
if (h.isWindows() && data.toString() === '\x04\r\n') {
176+
stdin.emit('end');
177+
} else {
178+
bufs.push(data);
179+
}
180+
}
171181
});
172182
stdin.on('end', function() {
173183
cb(null, Buffer.concat(bufs).toString());

0 commit comments

Comments
 (0)