zhaoyou
zhaoyou

Reputation: 308

Node.js exec git pull callback function argument incorrect

I get confused. The error is null, why stderr is not null ? how about git pull command exit status code ?

Source code:

var exec = require('child_process').exec;
var child = exec('git pull --rebase origin master', {
    encoding: 'utf8',
    timeout: 0,
    maxBuffer: 200*1024,
    killSignal: 'SIGTERM',
    cwd: 'd:/code/puller',
    env: null
 },
 function(error, stdout, stderr)  {
   console.log('error', error);
   console.log('stdout: ', stdout);
   console.log('stderr: ', stderr);
   if (error !== null) {
  console.log("exec error", error);
 }
});

output:

error null
stdout:  Current branch master is up to date.

stderr:  From xx.com/user/puller
* branch            master     -> FETCH_HEAD

Upvotes: 0

Views: 810

Answers (1)

Manasov Daniel
Manasov Daniel

Reputation: 1378

error is used for node.js errors. For examplem when output in console is more than 200K node.js will crash with error "Error: maxBuffer exceeded"

stderr is for errors in console like you have

Upvotes: 1

Related Questions