Fix: iojs-v2.3.2+ input stream can not read first line. (#18)

This commit is contained in:
anseki 2015-08-23 14:24:37 +09:00
parent 8abae72910
commit 274d13a44b
2 changed files with 13 additions and 2 deletions

View file

@ -80,11 +80,22 @@ function _readlineSync(options) {
return fsB;
}
function getVerNum(ver) {
var nums = ver.replace(/^\D+/, '').split('.');
var verNum = 0;
if ((nums[0] = +nums[0])) { verNum += nums[0] * 10000; }
if ((nums[1] = +nums[1])) { verNum += nums[1] * 100; }
if ((nums[2] = +nums[2])) { verNum += nums[2]; }
return verNum;
}
if (typeof fdR !== 'string') { return; }
fdR = null;
if (IS_WIN) {
if (process.stdin.isTTY) {
// iojs-v2.3.2+ input stream can't read first line. (#18)
// ** Don't get process.stdin before check! **
if (getVerNum(process.version) < 20302 && process.stdin.isTTY) {
process.stdin.pause();
fdR = process.stdin.fd;
ttyR = process.stdin._handle;

View file

@ -1,6 +1,6 @@
{
"name": "readline-sync",
"version": "1.2.19",
"version": "1.2.20",
"title": "readlineSync",
"description": "Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).",
"keywords": [