-
-
Save Marak/1229945 to your computer and use it in GitHub Desktop.
Read in data piped ala `cat config.json | node app.js`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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