diff --git a/README.md b/README.md index f214c1a..b7e4b35 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ In lieu of a formal styleguide, take care to maintain the existing coding style. ## Release History +0.1.5 - Externalize common code to separat modules 0.1.4 - Added support for cli arguments 0.1.3 - Added support for event 0.1.2 - Added verbose logging diff --git a/package.json b/package.json index 6303d2f..6bc8847 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grunt-semver", "description": "Semantic versioning for grunt", - "version": "0.1.4", + "version": "0.1.5", "homepage": "https://github.com/mikaelkaron/grunt-semver", "author": { "name": "Mikael Karon", @@ -22,7 +22,9 @@ ], "main": "Gruntfile.js", "dependencies": { - "semver": "~2.1" + "semver": "~2.1", + "grunt-util-options": "~0.0.1", + "grunt-util-process": "~0.0.1" }, "devDependencies": { "grunt-contrib-jshint": "~0.6.0", diff --git a/tasks/semver.js b/tasks/semver.js index 942f340..f536859 100644 --- a/tasks/semver.js +++ b/tasks/semver.js @@ -11,6 +11,8 @@ module.exports = function(grunt) { var semver = require("semver"); var _ = grunt.util._; + var _process = require("grunt-util-process")(grunt); + var _options = require("grunt-util-options")(grunt); var SPACE = "space"; var PHASE = "phase"; var PART = "part"; @@ -50,39 +52,14 @@ module.exports = function(grunt) { // Register SEMVER task grunt.task.registerMultiTask(SEMVER, "Semantic versioner for grunt", function (phase, part, build) { - // Get options (with defaults) - var options = this.options(OPTIONS); - - // Store some locals - var name = this.name; - var target = this.target; - var args = this.args; - - // Populate `options` with values - _.each([ PHASE, PART, BUILD ], function (key, index) { - options[key] = _.find([ - args[index], - grunt.option([ name, target, key ].join(".")), - grunt.option([ name, key ].join(".")), - grunt.option(key), - options[key] - ], function (value) { - return grunt.util.kindOf(value) !== "undefined"; - }); - }); - - // Process `options` with template - _.each([ PHASE, PART, BUILD ], function (key) { - var value = options[key]; - - if (grunt.util.kindOf(value) === "string") { - options[key] = grunt.template.process(value, { - "delimiters" : SEMVER - }); - } - }); + var me = this; + + // Get options and process + var options = _process.call(_options.call(me, me.options(OPTIONS), PHASE, PART, BUILD), { + "delimiters" : SEMVER + }, PHASE, PART, BUILD); - // Process arguments + // Update parameters phase = options[PHASE]; part = options[PART]; build = options[BUILD];