Files
handlebars.js/tasks/version.js
T
kpdecker e3d3eda2e1 Add full support for es6
Converts the tool chain to use babel, eslint, and webpack vs. the previous proprietary solutions.

Additionally begins enforcing additional linting concerns as well as updates the code to reflect these rules.

Fixes #855
Fixes #993
2015-04-16 16:43:01 -05:00

42 lines
1.3 KiB
JavaScript

var async = require('async'),
git = require('./util/git'),
semver = require('semver');
module.exports = function(grunt) {
grunt.registerTask('version', 'Updates the current release version', function() {
var done = this.async(),
pkg = grunt.config('pkg'),
version = grunt.option('ver');
if (!semver.valid(version)) {
throw new Error('Must provide a version number (Ex: --ver=1.0.0):\n\t' + version + '\n\n');
}
pkg.version = version;
grunt.config('pkg', pkg);
grunt.log.writeln('Updating to version ' + version);
async.each([
['lib/handlebars/base.js', /var VERSION = ['"](.*)['"];/, 'var VERSION = "' + version + '";'],
['components/bower.json', /"version":.*/, '"version": "' + version + '",'],
['components/handlebars.js.nuspec', /<version>.*<\/version>/, '<version>' + version + '</version>']
],
function(args, callback) {
replace.apply(undefined, args);
grunt.log.writeln(' - ' + args[0]);
git.add(args[0], callback);
},
function() {
grunt.task.run(['default']);
done();
});
});
function replace(path, regex, replace) {
var content = grunt.file.read(path);
content = content.replace(regex, replace);
grunt.file.write(path, content);
}
};