Grunt: Include commit in header if passed as ENV arg, mostly for Jenkins

This commit is contained in:
Jörn Zaefferer 2012-06-18 19:25:24 +02:00
parent 80295ed0e5
commit ab542c11ca

View File

@ -5,7 +5,7 @@
* *
*/ */
/*global config:true, task:true*/ /*global config:true, task:true, process:true*/
module.exports = function( grunt ) { module.exports = function( grunt ) {
// readOptionalJSON // readOptionalJSON
@ -228,6 +228,7 @@ module.exports = function( grunt ) {
optIn = !modules["*"], optIn = !modules["*"],
name = this.file.dest, name = this.file.dest,
excluded = {}, excluded = {},
version = config( "pkg.version" ),
excluder = function( flag, needsFlag ) { excluder = function( flag, needsFlag ) {
// explicit > implicit, so set this first and let it be overridden by explicit // explicit > implicit, so set this first and let it be overridden by explicit
if ( optIn && !modules[ flag ] && !modules[ "+" + flag ] ) { if ( optIn && !modules[ flag ] && !modules[ "+" + flag ] ) {
@ -243,6 +244,9 @@ module.exports = function( grunt ) {
} }
}; };
if ( process.env.COMMIT ) {
version += " " + process.env.COMMIT;
}
// figure out which files to exclude based on these rules in this order: // figure out which files to exclude based on these rules in this order:
// explicit > implicit (explicit also means a dependency/dependent that was explicit) // explicit > implicit (explicit also means a dependency/dependent that was explicit)
@ -312,7 +316,7 @@ module.exports = function( grunt ) {
// Embed Date // Embed Date
// Embed Version // Embed Version
compiled = compiled.replace( "@DATE", new Date() ) compiled = compiled.replace( "@DATE", new Date() )
.replace( "@VERSION", config("pkg.version") ); .replace( "@VERSION", version );
// Write concatenated source to file // Write concatenated source to file
file.write( name, compiled ); file.write( name, compiled );