readline fix for Linux

This commit is contained in:
Thomas Rory Gummerson committed 2019-07-02 12:35:29 +02:00
1 parent d329ff4131
commit 26e5fdea57
1 file changed
+8 -2
+8 -2
View File
@@ -9,9 +9,15 @@ const readline = () => {
while (char !== '\r' && char !== '\n') {
line += char;
try {
readSync(process.stdin.fd, buf, 0, 1);
const bytesRead = readSync(process.stdin.fd, buf, 0, 1);
if (bytesRead === 0) {
return line;
}
} catch (err) {
return line;
if (err.code === 'EOF') {
return line;
}
continue;
}
char = String(buf);
}