Skip to content

Instantly share code, notes, and snippets.

@snorremd
Last active December 25, 2015 12:59
Show Gist options
  • Save snorremd/6980835 to your computer and use it in GitHub Desktop.
Save snorremd/6980835 to your computer and use it in GitHub Desktop.
My attempt at a lazy-loading coffee task
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.JSON'),
watch: {
files: ['src/**/*.coffee', 'test/**/*.coffee', "app.coffee"],
task: ['coffeelint']
},
coffeelint: {
src: ['src/**/*.coffee', 'test/**/*.coffee'],
options: {
indentation: {
value: 4,
level: 'warn'
}
}
}
});
grunt.event.on('watch', function(action, filepath, target) {
//console.log(target + ': ' + filepath + ' has ' + action);
console.log(coffeelint);
grunt.config.set('coffeelint', {
changed: {
app: filepath,
force: true
}
});
grunt.config.set('coffee', {
changed: {
options: { bare: true, sourceMap: true },
files: [{ src: filepath, dest: "src/js", ext: '.js' }]
}
});
grunt.task.run(['coffeelint:changed', 'coffee:changed']);
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-coffeelint');
grunt.registerTask('default', ['watch']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment