diff --git a/README.md b/README.md index f3560a7..40363a9 100644 --- a/README.md +++ b/README.md @@ -103,3 +103,4 @@ Thanks :beer: * To [@lapanoid](https://github.com/lapanoid) for passing `opts` down to `git.tag` * To [@brianmhunt](https://github.com/brianmhunt) for suggesting the `version` parameter * To [@adambuczynski](https://github.com/adambuczynski) for option to customize tag label +* To [@mjeanroy](https://github.com/mjeanroy) for a gulp-util obsoletion update diff --git a/index.js b/index.js index c7dff61..792f9f8 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ var map = require('map-stream'), log = require('fancy-log'), colors = require('ansi-colors'), - git = require('gulp-git') + git = require('gulp-git'); /** * @param opts {object} Module options, passed _also_ to underlying `git.tag` @@ -11,25 +11,29 @@ var map = require('map-stream'), * @param opts.label {string?} Label to use for tagging, defaults to 'Tagging as %t'. %t will be replaced by the tag name. * @param opts.version {string?} Alternatively, just pass the version string here. Default: undefined. */ -module.exports = function(opts) { - if(!opts) opts = {} - if(!opts.key) opts.key = 'version' - if(typeof opts.prefix === 'undefined') opts.prefix = 'v' - if(typeof opts.push === 'undefined') opts.push = true - if(typeof opts.label === 'undefined') opts.label = 'Tagging as %t' +module.exports = function (opts) { + if (!opts) opts = {}; + if (!opts.key) opts.key = 'version'; + if (typeof opts.prefix === 'undefined') opts.prefix = 'v'; + if (typeof opts.push === 'undefined') opts.push = true; + if (typeof opts.label === 'undefined') opts.label = 'Tagging as %t'; function modifyContents(file, cb) { - var version = opts.version // OK if undefined at this time - if(!opts.version) { - if(file.isNull()) return cb(null, file) - if(file.isStream()) return cb(new Error('gulp-tag-version: streams not supported')) + var version = opts.version; // OK if undefined at this time + if (!opts.version) { + if (file.isNull()) { + return cb(null, file); + } + if (file.isStream()) { + return cb(new Error('gulp-tag-version: streams not supported')); + } var json = JSON.parse(file.contents.toString()); version = json[opts.key] } - var tag = opts.prefix+version - var label = opts.label.replace('%t', tag) - log('Tagging as: '+colors.cyan(tag)) + var tag = opts.prefix + version; + var label = opts.label.replace('%t', tag); + log('Tagging as: ' + colors.cyan(tag)); git.tag(tag, label, opts, cb) } diff --git a/package.json b/package.json index 025ca65..1ee7ccc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-tag-version", - "version": "1.3.0", + "version": "1.3.1", "description": "Tag git repository with current package version", "main": "index.js", "scripts": {