How to detect if Node's process.stdout is being piped?

Viewed 4760

Is there any way I can detect if the output from my Node.js script is being piped to something other then the terminal?

I would like some way of detecting if this is happening:

node myscript.js | less

Or if this is happening:

node myscript.js

2 Answers
Related