-
-
Save patrickandre/3969040 to your computer and use it in GitHub Desktop.
grunt.js example
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
var proc = require('child_process'); | |
config.init({ | |
lint: { | |
files : [ 'hoge.js', 'fuga.js' ] | |
}, | |
concat: { | |
'all.js' : [ 'hoge.js', 'fuga.js', 'cofall.js', '_coftemp.js' ] | |
}, | |
watch: { | |
files: [ 'hoge.js', 'fuga.js', 'cof1.coffee', 'cof2.coffee' ], | |
tasks: 'coffee concat min notifyOK' | |
}, | |
min: { | |
'all.min.js': [ 'all.js' ] | |
}, | |
coffee: { | |
'_coftemp.js': [ 'cof1.coffee', 'cof2.coffee' ] | |
} | |
}); | |
function notifyError(err, sout, serr, done){ | |
proc.exec("growlnotify -t 'COFFEE COMPILE ERROR!' -m '" + serr + "'"); | |
done(false); | |
} | |
function notifyOK(){ | |
proc.exec("growlnotify -t 'grunt.js' -m '\(^o^)/'"); | |
} | |
task.registerBasicTask('coffee', 'compile CoffeeScripts', function(data, name) { | |
var done = this.async(); | |
var command = 'coffee -j ' + name + ' -c ' + data.join(' '); | |
var out = proc.exec(command, function(err, sout, serr){ | |
if(err || sout || serr){ | |
notifyError(err, sout, serr, done); | |
}else{ | |
done(); | |
} | |
}); | |
}); | |
task.registerTask('notifyOK', 'done!', function(){ | |
notifyOK(); | |
}); | |
task.registerTask('default', 'coffee concat notifyOK'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment