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

Commit

Permalink
update version, readme and code style
Browse files Browse the repository at this point in the history
  • Loading branch information
ikari-pl committed Dec 25, 2017
1 parent ead4f73 commit ecad05e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 18 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit ecad05e

Please sign in to comment.