Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't concat-stream working with process.stdin.pipe()?

Tags:

node.js

Here's my code:

var concat = require('concat-stream');
process.stdin.pipe(concat(function(){console.log("output")}));

What I'm expecting this to do is output "output" every time I enter input into the console, but this doesn't work. Does anyone have an idea why this isn't working? If I do a fs.createReadStream() buffer, it works fine, just not with process.stdin.pipe(). I've used process.stdin.pipe() for other things though, and they worked fine.

Thanks in advance!

like image 313
Zane Hitchcox Avatar asked Oct 20 '22 03:10

Zane Hitchcox


1 Answers

The reason you get no output is because you're not actually closing stdin, which is what concat-stream is looking for so that it knows no more data is coming.

like image 172
mscdex Avatar answered Nov 15 '22 05:11

mscdex