I'm trying to get the result of git shortlog on a repository with nodejs this way:
var exec = require('child_process').exec; exec("cd /tmp/"+folder +" && git shortlog", {maxBuffer: 500*1024}, function(error, stdout, stderror){ console.log(arguments); }); My callback is never called with this method, the program appears processing something indefinitely.
When I launch this command in my prompt I've the results.
Trying to redirect the result to a file create an empty file :
"cd /tmp/"+folder +" && git shortlog > stats.txt" But if I use git log instead I've got my results.
Do you know why my callback is never called with git shortlog ?
Edit : I've the same result using spawn :
exec("cd /tmp/"+folder, function(err){ if(err){ throw err; } var shortlog = spawn('git', ['shortlog']); shortlog.stdout.on('data', function (data) { console.log('stdout: ' + data); }); shortlog.stderr.on('data', function (data) { console.log('stderr: ' + data); }); shortlog.on('close', function (code) { console.log('child process exited with code ' + code); }); }); Edit 2 : process.chdir() doesn't change anything :
process.chdir('/tmp/'+folder); var shortlog = spawn('git', ['shortlog']); shortlog.stdout.on('data', function (data) { console.log('stdout: ' + data); });