Skip to content

Commit

Permalink
Made options more generic so tasks other than concat can be provided …
Browse files Browse the repository at this point in the history
…(e.g. uglify)
  • Loading branch information
Chris Gross committed Apr 2, 2013
1 parent f072795 commit a6ae2fa
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions tasks/angular-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,28 @@ module.exports = function(grunt) {
grunt.file.write(dest, compiled);
grunt.log.writeln('File ' + dest.cyan + ' created.');

if (options.concat){
var concat = grunt.config('concat') || {};
var concatSrc = concat[options.concat];
if (grunt.util.kindOf(concatSrc) === 'object'){
concatSrc = concat[options.concat].src;
if (options.updatetask){
if (!options.updatetask.task || !options.updatetask.target){
grunt.log.error('Incorrect configuration. updatetask is missing \'task\' or \'target\'.');
done(false);
return;
}
if (grunt.util.kindOf(concatSrc) !== 'array'){
grunt.log.error('Unable to update concat config. Unable to find valid concat config for ' + options.concat.cyan + '.');
var task = grunt.config(options.updatetask.task) || {};
var target = task[options.updatetask.target];
if (grunt.util.kindOf(target) === 'object'){
target = target.src;
}
if (grunt.util.kindOf(target) !== 'array'){
grunt.log.error('Unable to update '+options.updatetask.task+' config. Unable to find valid config for ' + options.updatetask.target.cyan + '.');
done(false);
return;
} else {
concatSrc.push(dest);
grunt.config('concat',concat);
grunt.log.subhead('Updating concat config. Config is now:').writeln(' ' + util.inspect(concat,false,4,true));
target.push(dest);
grunt.config(options.updatetask.task,task);
grunt.log.subhead('Updating '+options.updatetask.task+' config. Config is now:').writeln(' ' + util.inspect(target,false,4,true));
}
}

done();
}
});
Expand Down

0 comments on commit a6ae2fa

Please sign in to comment.