Tweak bower_json Grunt task to be more configurable

This commit is contained in:
Eric Ferraiuolo 2014-02-07 03:43:40 -05:00
parent 1f9ec2a22d
commit 5ee9222705
2 changed files with 23 additions and 8 deletions

View File

@ -13,12 +13,16 @@ grunt.initConfig({
bower_json: {
release: {
main: 'pure.css'
values: {
main: 'pure.css'
},
dest: 'build/'
}
},
// -- Clean Config ---------------------------------------------------------
clean: {
build : ['build/'],
build_res: ['build/*-r.css'],
@ -34,9 +38,10 @@ grunt.initConfig({
expand : true,
flatten: true
},
release: {
src : '{LICENSE.md,README.md,HISTORY.md}',
dest : 'build/'
src : '{LICENSE.md,README.md,HISTORY.md}',
dest: 'build/'
}
},
@ -258,7 +263,7 @@ grunt.registerTask('release', [
'default',
'clean:release',
'copy:release',
'bower_json',
'bower_json:release',
'compress:release'
]);

View File

@ -1,8 +1,18 @@
'use strict';
var path = require('path');
module.exports = function (grunt) {
grunt.registerMultiTask('bower_json', 'Modifies bower.json "main".', function () {
grunt.config('bower.main', this.data.main);
grunt.file.write('build/bower.json', JSON.stringify(grunt.config('bower'),null,' '));
grunt.registerMultiTask('bower_json', 'Modifies bower.json file.', function (target) {
var values = this.data.values;
Object.keys(values).forEach(function (key) {
grunt.config.set('bower.' + key, values[key]);
grunt.log.writeln('Updated Bower ' +
String(key).cyan + ': ' + String(values[key]).cyan);
});
grunt.file.write(path.join(this.data.dest, 'bower.json'),
JSON.stringify(grunt.config('bower'), null, ' '));
});
};