diff --git a/lib/readline-sync.js b/lib/readline-sync.js index f1f6dcf..f9e3ad7 100644 --- a/lib/readline-sync.js +++ b/lib/readline-sync.js @@ -70,7 +70,7 @@ function _readlineSync(options) { if (_DBG_checkOptions) { _DBG_checkOptions(options); } (function() { // open TTY - var fsB, constants; + var fsB, constants, verNum; function getFsB() { if (!fsB) { @@ -80,22 +80,24 @@ 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) { // 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) { + // Fixed v5.1.0 https://nodejs.org/en/blog/release/v5.1.0/ + // Fixed v4.2.4 (LTS) https://nodejs.org/en/blog/release/v4.2.4/ + verNum = (function(ver) { // getVerNum + 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; + })(process.version); + if (!(verNum >= 20302 && verNum < 40204 || verNum >= 50000 && verNum < 50100) && + process.stdin.isTTY) { process.stdin.pause(); fdR = process.stdin.fd; ttyR = process.stdin._handle; diff --git a/package.json b/package.json index dc51539..d0402d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "readline-sync", - "version": "1.2.21", + "version": "1.2.22", "title": "readlineSync", "description": "Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).", "keywords": [