您能帮忙翻译一下使用grunt运行节点exec命令的示例吗?
echo
命令正在执行,创建了 hello-world.txt
,但回调函数中的 grunt.log.writeln
命令没有触发。
var exec = require('child_process').exec,
child;
child = exec('echo hello, world! > hello-world.txt',
function(error, stdout, stderr){
grunt.log.writeln('stdout: ' + stdout);
grunt.log.writeln('stderr: ' + stderr);
if (error !== null) {
grunt.log.writeln('exec error: ' + error);
}
}
);
参考资料:
http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options