Fix: iojs-v2.3.2+ input stream can not read first line. (#18)
This commit is contained in:
parent
8abae72910
commit
274d13a44b
2 changed files with 13 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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": [
|
||||
|
|
Loading…
Reference in a new issue