Skip to content

Instantly share code, notes, and snippets.

@polotek
Forked from heapwolf/pipeaccept.js
Created May 18, 2011 01:16
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save polotek/977813 to your computer and use it in GitHub Desktop.
Save polotek/977813 to your computer and use it in GitHub Desktop.
accepting input from a pipe, nodejs
var data;
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
data += chunk;
});
process.stdin.on('end', function() {
callback(data)
});
setInterval(function() {
console.error('working');
}, 1e3);
@prewk
Copy link

prewk commented Jun 2, 2015

You should change var data; to var data = ''; or else the data will be "undefinedTHE_ACTUAL_DATA"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment