"use strict";varexec=require("child_process").exec;module.exports=function(grunt){grunt.registerTask("version","Commit a new version",function(version){if(!/\d\.\d+\.\d+(?:-pre)?/.test(version)){grunt.fatal("Version must follow semver release format: "+version);return;}vardone=this.async(),files=grunt.config("version.files"),rversion=/("version":\s*")[^"]+/;// Update version in specified filesfiles.forEach(function(filename){vartext=grunt.file.read(filename);text=text.replace(rversion,"$1"+version);grunt.file.write(filename,text);});// Add files to git indexexec("git add -A",function(err){if(err){grunt.fatal(err);return;}// Commit next pre versiongrunt.config("pkg.version",version);grunt.task.run(["build","uglify","dist","commit:'Update version to "+version+"'"]);done();});});};