summaryrefslogtreecommitdiff
path: root/lib/tty.js
diff options
context:
space:
mode:
authorBryan English <bryan@bryanenglish.com>2017-09-23 01:40:35 -0700
committerBryan English <bryan@bryanenglish.com>2017-10-22 16:51:10 -0700
commit27e12e75244343ffcde4b899a31e88d452fa4d6e (patch)
treeb6319edc862c0fbf506bb04030fb4748750b2b9e /lib/tty.js
parentb5569dbe8dee7f259644ef6b73b756d9ea2ba090 (diff)
downloadnode-new-27e12e75244343ffcde4b899a31e88d452fa4d6e.tar.gz
tty,doc: add type-check to isatty
Previously, various inputs other than non-negative integers would produce incorrect results. Added type-checking on input, returning false for anything other than non-negative integers. Also clarified in docs. PR-URL: https://github.com/nodejs/node/pull/15567 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'lib/tty.js')
-rw-r--r--lib/tty.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/tty.js b/lib/tty.js
index e8da49fbde..cf020f529d 100644
--- a/lib/tty.js
+++ b/lib/tty.js
@@ -30,7 +30,7 @@ const errors = require('internal/errors');
const readline = require('readline');
exports.isatty = function(fd) {
- return isTTY(fd);
+ return Number.isInteger(fd) && fd >= 0 && isTTY(fd);
};