I have the following (non-functioning) code:
var es = require('event-stream');
var cp = require('child_process');
es.pipeline(
es.child(cp.exec("ls")),
es.split(/[\t\s]+/),
es.map(function(data,cb){
if ( /\.txt$/.test(data) ) cb(null, data);
else cb();
}),
es.child(cp.exec("cat "+data)) // this doesn't work
)
The problem lies in the last stream es.child(cp.exec("cat "+data))
where data
is the chunk written from the map()
stream. how would one go about achieving this? Also please note that "ls" and "cat" are not the actual commands I am using but the principle of executing a dynamically-generated unix command and streaming the output is the same.