Skip to content

Commit 5ee9222

Browse files
committed
Tweak bower_json Grunt task to be more configurable
1 parent 1f9ec2a commit 5ee9222

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

Gruntfile.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ grunt.initConfig({
1313

1414
bower_json: {
1515
release: {
16-
main: 'pure.css'
16+
values: {
17+
main: 'pure.css'
18+
},
19+
20+
dest: 'build/'
1721
}
1822
},
1923

2024
// -- Clean Config ---------------------------------------------------------
21-
25+
2226
clean: {
2327
build : ['build/'],
2428
build_res: ['build/*-r.css'],
@@ -34,9 +38,10 @@ grunt.initConfig({
3438
expand : true,
3539
flatten: true
3640
},
41+
3742
release: {
38-
src : '{LICENSE.md,README.md,HISTORY.md}',
39-
dest : 'build/'
43+
src : '{LICENSE.md,README.md,HISTORY.md}',
44+
dest: 'build/'
4045
}
4146
},
4247

@@ -258,7 +263,7 @@ grunt.registerTask('release', [
258263
'default',
259264
'clean:release',
260265
'copy:release',
261-
'bower_json',
266+
'bower_json:release',
262267
'compress:release'
263268
]);
264269

tasks/bower_json.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
'use strict';
22

3+
var path = require('path');
4+
35
module.exports = function (grunt) {
4-
grunt.registerMultiTask('bower_json', 'Modifies bower.json "main".', function () {
5-
grunt.config('bower.main', this.data.main);
6-
grunt.file.write('build/bower.json', JSON.stringify(grunt.config('bower'),null,' '));
6+
grunt.registerMultiTask('bower_json', 'Modifies bower.json file.', function (target) {
7+
var values = this.data.values;
8+
9+
Object.keys(values).forEach(function (key) {
10+
grunt.config.set('bower.' + key, values[key]);
11+
grunt.log.writeln('Updated Bower ' +
12+
String(key).cyan + ': ' + String(values[key]).cyan);
13+
});
14+
15+
grunt.file.write(path.join(this.data.dest, 'bower.json'),
16+
JSON.stringify(grunt.config('bower'), null, ' '));
717
});
818
};

0 commit comments

Comments
 (0)