Last active
August 29, 2015 13:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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