Skip to content

Instantly share code, notes, and snippets.

@dmh2000
Last active August 29, 2015 13:56
Show Gist options
  • Save dmh2000/9060442 to your computer and use it in GitHub Desktop.
Save dmh2000/9060442 to your computer and use it in GitHub Desktop.
How to invoke external make when building a node.js module with Grunt
// use node 'child_process' to exec make
var exec = require('child_process').exec;
// register a custom task
grunt.registerTask('make','invoke external make',function() {
// set grunt task to async mode
var done = this.async();
// execute make (or any other external executable for that matter)
exec('make',function(error,stdout,stderr) {
// if the external task returns anything but 0,
// the error argument will be not null
if (error !== null) {
grunt.log.error(error);
}
else {
// 'stdout' is buffered output from the external task
grunt.log.writeln(stdout);
}
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment