Would you kindly help with the following example of a node exec command run with grunt?
The echo
command is executing, and hello-world.txt
is created, but the grunt.log.writeln
commands in the callback function aren't firing.
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);
}
}
);
References:
http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options