Add Grunt license task to stamp the Normalize.css and Yahoo! licenses

This task prepends the proper licenses to the built files as the very
last step of the `default` Grunt task.
This commit is contained in:
Eric Ferraiuolo 2013-05-14 16:59:18 -04:00
parent 52c6ac538b
commit bd63012fa1

View File

@ -12,12 +12,6 @@ grunt.initConfig({
BUILD_COMMENT: 'THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT!', BUILD_COMMENT: 'THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT!',
NORMALIZE_LICENSE: [
'/*! normalize.css v1.1.1 | MIT License | git.io/normalize */',
'/*! Copyright (c) Nicolas Gallagher and Jonathan Neal */',
'\n'
].join('\n'),
// -- Clean Config --------------------------------------------------------- // -- Clean Config ---------------------------------------------------------
clean: { clean: {
@ -173,6 +167,41 @@ grunt.initConfig({
} }
}, },
// -- License Config -------------------------------------------------------
license: {
normalize: {
options: {
banner: [
'/*!',
'normalize.css v1.1.1 | MIT License | git.io/normalize',
'Copyright (c) Nicolas Gallagher and Jonathan Neal',
'*/\n'
].join('\n')
},
expand: true,
cwd : 'build/',
src : ['base*.css', 'forms*.css', 'tables*.css', 'kimono*.css']
},
yahoo: {
options: {
banner: [
'/*!',
'Kimono <%= pkg.version %>',
'Copyright 2013 Yahoo! Inc. All rights reserved.',
'Licensed under the BSD License.',
'https://github.com/yui/kimono/blob/master/LICENSE.md',
'*/\n'
].join('\n')
},
expand: true,
src : ['build/*.css']
}
},
// -- Contextualize Config ------------------------------------------------- // -- Contextualize Config -------------------------------------------------
contextualize: { contextualize: {
@ -182,7 +211,7 @@ grunt.initConfig({
options: { options: {
prefix: '.k', prefix: '.k',
banner: '/* <%= BUILD_COMMENT %> */\n<%= NORMALIZE_LICENSE %>' banner: '/* <%= BUILD_COMMENT %> */\n'
} }
} }
} }
@ -202,7 +231,8 @@ grunt.registerTask('default', [
'concat:build', 'concat:build',
'clean:build_res', 'clean:build_res',
'cssmin', 'cssmin',
'concat:kimono' 'concat:kimono',
'license'
]); ]);
grunt.registerTask('import', [ grunt.registerTask('import', [
@ -223,6 +253,23 @@ grunt.registerTask('import-normalize', [
'contextualize:normalize' 'contextualize:normalize'
]); ]);
// -- License Task -------------------------------------------------------------
grunt.registerMultiTask('license', 'Stamps license banners on files.', function () {
var options = this.options({banner: ''}),
banner = grunt.template.process(options.banner),
tally = 0;
this.files.forEach(function (filePair) {
filePair.src.forEach(function (file) {
grunt.file.write(file, banner + grunt.file.read(file));
tally += 1;
});
});
grunt.log.writeln('Stampped license on ' + String(tally).cyan + ' files.');
});
// -- Contextualize Task ------------------------------------------------------- // -- Contextualize Task -------------------------------------------------------
grunt.registerMultiTask('contextualize', 'Makes Contextualized CSS files.', function () { grunt.registerMultiTask('contextualize', 'Makes Contextualized CSS files.', function () {