Commit e1944614 by Torkel Ödegaard

feat(grunt watch): optimized grunt watch, now only operates on changed files

parent 45c69fa6
...@@ -4,6 +4,7 @@ module.exports = function(config) { ...@@ -4,6 +4,7 @@ module.exports = function(config) {
return { return {
release: ['<%= destDir %>', '<%= tempDir %>', '<%= genDir %>'], release: ['<%= destDir %>', '<%= tempDir %>', '<%= genDir %>'],
gen: ['<%= genDir %>'], gen: ['<%= genDir %>'],
temp: ['<%= tempDir %>'] temp: ['<%= tempDir %>'],
css: ['<%= genDir %>/css']
}; };
}; };
module.exports = function(config) { module.exports = function(config, grunt) {
'use strict'; 'use strict';
return { grunt.event.on('watch', function(action, filepath) {
// css: { var newPath;
// files: [ '<%= srcDir %>/less#<{(||)}>#*.less' ],
// tasks: ['css'], grunt.log.writeln('File Changed: ' + filepath);
// options: {
// spawn: false if (/(\.html)$/.test(filepath)) {
// } newPath = filepath.replace(/^public/, 'public_gen');
// }, grunt.log.writeln('Copying to ' + newPath);
grunt.file.copy(filepath, newPath);
}
if (/(\.js)$/.test(filepath)) {
newPath = filepath.replace(/^public/, 'public_gen');
grunt.log.writeln('Copying to ' + newPath);
grunt.file.copy(filepath, newPath);
grunt.task.run('jshint');
grunt.task.run('jscs');
}
if (/(\.less)$/.test(filepath)) {
grunt.task.run('clean:css');
grunt.task.run('css');
}
if (/(\.ts)$/.test(filepath)) {
//changes changed file source to that of the changed file
var option = 'typescript.build.src';
var result = filepath;
grunt.config(option, result);
grunt.task.run('typescript:build');
grunt.task.run('tslint');
}
});
return {
copy_to_gen: { copy_to_gen: {
files: ['<%= srcDir %>/**/*'], files: ['<%= srcDir %>/**/*'],
tasks: [ tasks: [],
'clean:gen',
'copy:public_to_gen',
'css',
'typescript:build',
'jshint',
'jscs',
'tslint',
'karma:test'
],
options: { options: {
spawn: false spawn: false
} }
}, },
// typescript: {
// files: ['<%= srcDir %>/app#<{(||)}>#*.ts', '<%= srcDir %>/test#<{(||)}>#*.ts'],
// tasks: ['tslint', 'typescript:build'],
// options: {
// spawn: false
// }
// }
}; };
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment