Created
February 17, 2014 23:00
-
-
Save dmh2000/9060975 to your computer and use it in GitHub Desktop.
sample gruntfile with external make
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 strict'; | |
var exec = require('child_process').exec; | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
jshint: { | |
// define the files to lint | |
files: ['gruntfile.js', 'main.js', 'src/**/*.js', 'test/**/*.js'], | |
// configure JSHint (documented at http://www.jshint.com/docs/) | |
options: { | |
// more options here if you want to override JSHint defaults | |
globalstrict:true, | |
globals: { | |
jQuery: true, | |
console: true, | |
module: true, | |
require:true, | |
describe:true, | |
it:true | |
} | |
} | |
}, | |
mochaTest: { | |
test: { | |
options: { | |
reporter: 'spec' | |
}, | |
src: ['test/**/*.js'] | |
} | |
}, | |
watch: { | |
js : { | |
files: ['<%= jshint.files %>'], | |
tasks: ['jshint','mochaTest'] | |
}, | |
c : { | |
files: ['x.c'], | |
tasks: ['make'] | |
} | |
}, | |
make: { | |
files:['x.c'] | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-mocha-test'); | |
grunt.registerTask('make','invoke external make',function() { | |
var done = this.async(); | |
grunt.log.writeln('starting make'); | |
exec('make',function(error,stdout,stderr) { | |
if (error !== null) { | |
grunt.log.error(error); | |
} | |
else { | |
grunt.log.writeln(stdout); | |
} | |
done(); | |
}); | |
}); | |
// the default task can be run just by typing "grunt" on the command line | |
grunt.registerTask('default', ['jshint','mochaTest','make','watch']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment