Skip to content

Instantly share code, notes, and snippets.

@romaricpascal
Created July 26, 2013 23:17
Show Gist options
  • Save romaricpascal/6092876 to your computer and use it in GitHub Desktop.
Save romaricpascal/6092876 to your computer and use it in GitHub Desktop.
pre-commit Git hook that runs grunt to validate the sources before commit
#!/usr/bin/env node
var exec = require('child_process').exec;
// Runs the build task, in our case `grunt jshint`
exec('grunt jshint', function (error, stdout, stderr) {
// Build task output might be useful to the developer so let's print it
// We could also log it in a file
console.log(stdout);
// Depending on the result of the build, either print the error
// or exit successfully
var exitCode = 0;
if (error) {
console.log('Build script encountered an error :(');
console.log(stderr);
exitCode = -1;
}
process.exit(exitCode);
});
@romaricpascal
Copy link
Author

MIT Licenced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment