Skip to content

Instantly share code, notes, and snippets.

@vilmosioo
Created September 6, 2013 13:41
Show Gist options
  • Save vilmosioo/6463953 to your computer and use it in GitHub Desktop.
Save vilmosioo/6463953 to your computer and use it in GitHub Desktop.
Run grunt jshint before every commit. The commit fails if any warnings/errors are generated. Helps avoid "jshint fix" style commits
#!/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('Fix jshint errors before committing');
console.log(stderr);
exitCode = -1;
}
process.exit(exitCode);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment