Skip to content

Instantly share code, notes, and snippets.

@patrickandre
Forked from Takazudo/grunt.js
Created October 28, 2012 16:16
Show Gist options
  • Save patrickandre/3969040 to your computer and use it in GitHub Desktop.
Save patrickandre/3969040 to your computer and use it in GitHub Desktop.
grunt.js example
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