Skip to content

Commit

Permalink
Grunt task to tickle version # in platform and polymer builds
Browse files Browse the repository at this point in the history
--release option will prevent placing git revision at the end
  • Loading branch information
dfreedm committed Dec 18, 2013
1 parent c0c9a50 commit ea9e520
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tasks/version-number.js
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);
});
}
});
};

0 comments on commit ea9e520

Please sign in to comment.