Skip to content

Instantly share code, notes, and snippets.

@Marak
Forked from bmeck/pipedDataStream.js
Created September 20, 2011 18:49
Show Gist options
  • Save Marak/1229945 to your computer and use it in GitHub Desktop.
Save Marak/1229945 to your computer and use it in GitHub Desktop.
Read in data piped ala `cat config.json | node app.js`
var tty = require('tty');
exports.pipedDataStream = pipedDataStream;
//
// If there was piped input, it returns a ReadableStream of the content
// use "data" and "end" events as per the norm.
//
// Else returns falsey.
//
function pipedDataStream() {
if(!tty.isatty(0)) {
process.openStdin();
return process.stdin;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment