Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: specify return type for tty.isatty() #27154

Closed

Conversation

belochub
Copy link
Contributor

@belochub belochub commented Apr 9, 2019

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. tty Issues and PRs related to the tty subsystem. labels Apr 9, 2019
@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 9, 2019
@BridgeAR
Copy link
Member

BridgeAR commented Apr 9, 2019

@vsemozhetbyt
Copy link
Contributor

Node.js Collaborators, please, add 👍 here if you approve fast-tracking.

@vsemozhetbyt vsemozhetbyt added the fast-track PRs that do not need to wait for 48 hours to land. label Apr 9, 2019
@vsemozhetbyt
Copy link
Contributor

Landed in 643a2fa
Thank you!

vsemozhetbyt pushed a commit that referenced this pull request Apr 9, 2019
PR-URL: #27154
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
@silverwind
Copy link
Contributor

FWFI, boolean is not entirely correct, it can also be undefined in some edge cases:

#26946
#2333

@BridgeAR
Copy link
Member

@silverwind those issues seem to be related to isTTY but not to isatty()? Looking at the functions code, I am pretty certain it can only return a boolean and never undefined.

@silverwind
Copy link
Contributor

@BridgeAR ah, you're actually correct. I assumed they use the same implementation underneath, but this seems not the case.

parent.js

require("child_process").exec("node child.js", (_, stdout) => process.stdout.write(stdout));

child.js

console.log(process.stdin.isTTY);
console.log(process.stdin.isRaw);
console.log(process.stdin.setRawMode);
console.log(process.stdout.columns);
console.log(require("tty").isatty(process.stdin));
console.log(require("tty").isatty(process.stdout));

node parent.js prints

undefined
undefined
undefined
undefined
false
false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. fast-track PRs that do not need to wait for 48 hours to land. tty Issues and PRs related to the tty subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants