问题
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!
回答1:
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.
来源:https://stackoverflow.com/questions/25225158/why-isnt-concat-stream-working-with-process-stdin-pipe