mirror of
https://github.com/bdnugget/CodinGame-CLI.git
synced 2026-11-07 08:57:29 +00:00
readline fix for Linux
This commit is contained in:
1 parent
d329ff4131
commit
26e5fdea57
1 file changed
+8
-2
+8
-2
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user