var extend = require('extend'); var spawn = require('child_process').spawn; var csv = require('csv'); var ls = spawn('git', ['log']); ls.stdout.on('data', function (data) { parser.write(data); }); ls.on('close', function (code) { // parser.end(); // either I call parser.end() explicitly and it // gets called before readable work finishes, or it // never gets called at all console.log('exit code ' + code); }); var parser = csv.parse({delimiter: '\t'}); parser.on('readable', function() { while(data = parser.read()) { setTimeout(function() { console.log('---'); }, 10); } }); parser.on('end', function() { console.log('parser end'); }); parser.on('finish', function() { console.log('parser finish'); });