Skip to content

Instantly share code, notes, and snippets.

@natpen
Created July 29, 2015 17:52
Show Gist options
  • Save natpen/9ea5e5c7b7ad94e8bd8b to your computer and use it in GitHub Desktop.
Save natpen/9ea5e5c7b7ad94e8bd8b to your computer and use it in GitHub Desktop.
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');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment