Skip to content

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

Closed
belochub wants to merge 1 commit into
nodejs:masterfrom
belochub:doc-add-return-type-for-tty-isatty
Closed

belochub wants to merge 1 commit into
nodejs:masterfrom
belochub:doc-add-return-type-for-tty-isatty

Conversation

@belochub

@belochub belochub commented Apr 9, 2019

Copy link
Copy Markdown
Contributor
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 Node.js documentation. tty Issues and PRs related to the tty subsystem. labels Apr 9, 2019
@BridgeAR BridgeAR added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Apr 9, 2019
@BridgeAR

BridgeAR commented Apr 9, 2019

Copy link
Copy Markdown
Member

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

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

@vsemozhetbyt vsemozhetbyt added the fast-track PRs proposed for a shorter-than-standard waiting period before landing. label Apr 9, 2019
@vsemozhetbyt

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

#26946
#2333

@BridgeAR

Copy link
Copy Markdown
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
Copy Markdown
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 with CI started, the required approvals, and no outstanding review comments. doc Issues and PRs related to Node.js documentation. fast-track PRs proposed for a shorter-than-standard waiting period before landing. tty Issues and PRs related to the tty subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants