如题,在终端上可以正确执行node命令并得到相应结果,但是用nodejs的exec在脚本中调用执行node命令得不到回应,是否和环境有关?如何设置?求教…(windows下正常)
excCommond: function (command, isShowLog, callBack) {
if (.isString(command)) {
command = [command];
}
var isCallBack = true;
if (!.isArray(command)) {
callBack && callBack();
return;
}
var child_process = require(‘child_process’);
var child = child_process.exec(command.join(’&&’));
child.stdout.on(‘data’, function (data) {
isShowLog && console.log(data);
});
child.stderr.on('data', function (data) {
isShowLog && console.log(data);
isCallBack = false;
});
child.on('exit', function (code) {
console.log('------------ 执行完毕' + code);
isCallBack && callBack && callBack();
});
}
这是我之前写工具的时候 ,封装的一个接口,你提出来就行了,
需要模块: underscore child_process

