How to detect if the type of the process.stdout/stdin is a terminal or a pipe/file? A snipped in JavaScript is required:
function isTerminal(){ ...... } The easiest way to identity if the type of the process.stdout is a pipe/file would be process.stdout.isTTY (0.8 +):
$ node -p -e "Boolean(process.stdout.isTTY)" | cat false $ node -p -e "Boolean(process.stdout.isTTY)" true You can also test the following with the tty module for finer grained control:
if (require('tty').isatty(1)) { // terminal }