Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
add dot notation
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlacy committed Feb 23, 2015
1 parent 78b42d2 commit 2d99aab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var gutil = require('gulp-util');
var through = require('through2');
var semver = require('semver');
var Dot = require('dot-object');

var setDefaultOptions = function(opts) {
opts = opts || {};
Expand Down Expand Up @@ -38,7 +39,7 @@ module.exports = function(opts) {
var indent = opts.indent;
var type = opts.type;

var content, json;
var content, json, ver;

return through.obj(function(file, enc, cb) {
if (file.isNull()) {
Expand All @@ -62,17 +63,25 @@ module.exports = function(opts) {
gutil.log('Creating key', gutil.colors.red(key), 'with version:', gutil.colors.cyan(version));
}
content[key] = version;
ver = content[key];
}
else if (semver.valid(content[key])) {
// increment the key with type
content[key] = semver.inc(content[key], type);
ver = content[key];
}
else if (key.indexOf('.') > -1) {
var dot = new Dot();
var value = dot.pick(key, content);
ver = semver.inc(value, type);
dot.str(key, ver, content);
}
else {
return cb(new gutil.PluginError('gulp-bump', 'Detected invalid semver ' + key, {fileName: file.path, showStack: false}));
}
file.contents = new Buffer(JSON.stringify(content, null, indent || space(json)) + possibleNewline(json));

gutil.log('Bumped ' + gutil.colors.magenta(key) + ' to: ' + gutil.colors.cyan(content[key]));
gutil.log('Bumped ' + gutil.colors.magenta(key) + ' to: ' + gutil.colors.cyan(ver));
cb(null, file);
});
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"author": "Steve Lacy <me@slacy.me> (http://slacy.me)",
"main": "./index.js",
"dependencies": {
"dot-object": "^0.6.0",
"gulp-util": "^3.0.3",
"semver": "^4.3.0",
"through2": "^0.5.1"
Expand Down

0 comments on commit 2d99aab

Please sign in to comment.