-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grunt task to tickle version # in platform and polymer builds
--release option will prevent placing git revision at the end
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2013 The Polymer Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
module.exports = function(grunt) { | ||
grunt.registerTask('version', 'Update version number for builds', function() { | ||
grunt.config.requires('pkg.version'); | ||
var version = grunt.config('pkg.version'); | ||
// spit back pkg.version if "release" is true | ||
var release = grunt.option('release'); | ||
var done = this.async(); | ||
|
||
function getRevision(callback) { | ||
grunt.util.spawn({ | ||
cmd: 'git', | ||
args: ['rev-parse', '--short', 'HEAD'] | ||
}, callback); | ||
} | ||
|
||
if (release) { | ||
grunt.config('buildversion', version); | ||
done(null); | ||
} else { | ||
getRevision(function(error, ref) { | ||
if (!error) { | ||
grunt.config('buildversion', version + '-' + ref); | ||
} | ||
done(error); | ||
}); | ||
} | ||
}); | ||
}; |