From 488b74d68bc259c066351dd24adebbdeb53f4d24 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Tue, 19 Mar 2013 09:10:23 +0100 Subject: [PATCH] doc: mention `process.*.isTTY` under `process` --- doc/api/process.markdown | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/api/process.markdown b/doc/api/process.markdown index 639bdd74bd3..c345da76900 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