我感到困惑。错误为null,为什么stderr不为null? git pull命令退出状态代码怎么样?
源代码:
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);
}
});
输出:
error null
stdout: Current branch master is up to date.
stderr: From xx.com/user/puller
* branch master -> FETCH_HEAD
答案 0 :(得分:0)
error
用于node.js错误。例如,当控制台中的输出超过200K node.js将崩溃并出现错误"Error: maxBuffer exceeded"
stderr
用于控制台中的错误