summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Bynens <mathias@qiwi.be>2013-03-19 09:10:23 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2013-03-25 13:54:32 +0100
commit488b74d68bc259c066351dd24adebbdeb53f4d24 (patch)
treed33b2fb37c0bbc5f74f0c09af1d77a9f5afae60c
parent44843a60629ab5951a9c54ac6bf74208d607e3e0 (diff)
downloadnode-new-488b74d68bc259c066351dd24adebbdeb53f4d24.tar.gz
doc: mention `process.*.isTTY` under `process`
-rw-r--r--doc/api/process.markdown14
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/api/process.markdown b/doc/api/process.markdown
index 639bdd74bd..c345da7690 100644
--- a/doc/api/process.markdown
+++ b/doc/api/process.markdown
@@ -93,6 +93,20 @@ that writes to them are usually blocking. They are blocking in the case
that they refer to regular files or TTY file descriptors. In the case they
refer to pipes, they are non-blocking like other streams.
+To check if Node is being run in a TTY context, read the `isTTY` property
+on `process.stderr`, `process.stdout`, or `process.stdin`:
+
+ $ node -p "Boolean(process.stdin.isTTY)"
+ true
+ $ echo "foo" | node -p "Boolean(process.stdin.isTTY)"
+ false
+
+ $ node -p "Boolean(process.stdout.isTTY)"
+ true
+ $ node -p "Boolean(process.stdout.isTTY)" | cat
+ false
+
+See [the tty docs](tty.html#tty_tty) for more information.
## process.stderr