Skip to content

Commit

Permalink
Merge branch 'release/0.1.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkaron committed Aug 22, 2013
2 parents 892e678 + 60b3546 commit 738b6be
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 34 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
41 changes: 9 additions & 32 deletions tasks/semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 738b6be

Please sign in to comment.