Created
October 28, 2012 13:36
-
-
Save metaskills/3968623 to your computer and use it in GitHub Desktop.
Example Grunt.js Watch To Run Cakefile Tests
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
/* | |
An example grunt.js file to watch all my coffeescript files, then run `cake test` | |
on changes. My Cakefile is setup to run run tests for different DOM libraries using | |
tasks name like `test:jquery18` and `test:zepto10`, so the grunt multi task example | |
below will parse these from the tasks `this.nameArgs`. | |
*/ | |
spawn = require('child_process').spawn; | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
cake: { | |
test: {} | |
}, | |
watch: { | |
files: '**/*.coffee', | |
tasks: ['cake:test:all'] | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.registerMultiTask('cake', 'Test with Cakefile.', function(){ | |
var args = this.nameArgs.split(':'); | |
var testArg = args.slice(1, args.length).join(':'); | |
var done = this.async(); | |
var cakeTest = spawn('cake', [testArg]); | |
cakeTest.stdout.on('data', function(data){ grunt.log.write(data.toString()); }) | |
cakeTest.on('exit', function(code){ done(code); }) | |
}); | |
grunt.registerTask('default', 'watch'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My
package.json
has the following dev dependencies.