git-semver-tags
Advanced tools
Comparing version 2.0.3 to 3.0.0
@@ -6,2 +6,16 @@ # Change Log | ||
# [3.0.0](https://github.com/conventional-changelog/conventional-changelog/compare/git-semver-tags@2.0.3...git-semver-tags@3.0.0) (2019-07-29) | ||
* refactor!: modify gitSemverTags to take options first (#390) ([dc8aeda](https://github.com/conventional-changelog/conventional-changelog/commit/dc8aeda)), closes [#390](https://github.com/conventional-changelog/conventional-changelog/issues/390) | ||
### BREAKING CHANGES | ||
* gitSemverTags now takes options followed by callback. | ||
## [2.0.3](https://github.com/conventional-changelog/conventional-changelog/compare/git-semver-tags@2.0.2...git-semver-tags@2.0.3) (2019-05-18) | ||
@@ -8,0 +22,0 @@ |
17
cli.js
@@ -10,8 +10,13 @@ #!/usr/bin/env node | ||
Options | ||
--lerna parse lerna style git tags | ||
--package when listing lerna style tags, filter by a package | ||
--tagPrefix prefix to remove from the tags during their processing` | ||
--cwd path to git repository to be searched | ||
--lerna parse lerna style git tags | ||
--package <name> when listing lerna style tags, filter by a package | ||
--tagPrefix <prefix> prefix to remove from the tags during their processing` | ||
) | ||
gitSemverTags(function (err, tags) { | ||
gitSemverTags({ | ||
lernaTags: args.flags.lerna, | ||
package: args.flags.package, | ||
tagPrefix: args.flags.tagPrefix | ||
}, function (err, tags) { | ||
if (err) { | ||
@@ -23,6 +28,2 @@ console.error(err.toString()) | ||
console.log(tags.join('\n')) | ||
}, { | ||
lernaTags: args.flags.lerna, | ||
package: args.flags.package, | ||
tagPrefix: args.flags.tagPrefix | ||
}) |
27
index.js
'use strict' | ||
var proc = require('process') | ||
var exec = require('child_process').exec | ||
@@ -16,13 +17,15 @@ var semverValid = require('semver').valid | ||
module.exports = function (callback, opts) { | ||
opts = opts || {} | ||
module.exports = function gitSemverTags (opts, callback) { | ||
if (typeof opts === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
var options = Object.assign({ maxBuffer: Infinity, cwd: proc.cwd() }, opts) | ||
if (opts.package && !opts.lernaTags) { | ||
callback(Error('opts.package should only be used when running in lerna mode')) | ||
if (options.package && !options.lernaTags) { | ||
callback(new Error('opts.package should only be used when running in lerna mode')) | ||
return | ||
} | ||
exec(cmd, { | ||
maxBuffer: Infinity | ||
}, function (err, data) { | ||
exec(cmd, options, function (err, data) { | ||
if (err) { | ||
@@ -35,4 +38,4 @@ callback(err) | ||
var tagPrefixRegexp | ||
if (opts.tagPrefix) { | ||
tagPrefixRegexp = new RegExp('^' + opts.tagPrefix + '(.*)') | ||
if (options.tagPrefix) { | ||
tagPrefixRegexp = new RegExp('^' + options.tagPrefix + '(.*)') | ||
} | ||
@@ -43,7 +46,7 @@ data.split('\n').forEach(function (decorations) { | ||
var tag = match[1] | ||
if (opts.lernaTags) { | ||
if (lernaTag(tag, opts.package)) { | ||
if (options.lernaTags) { | ||
if (lernaTag(tag, options.package)) { | ||
tags.push(tag) | ||
} | ||
} else if (opts.tagPrefix) { | ||
} else if (options.tagPrefix) { | ||
var matches = tag.match(tagPrefixRegexp) | ||
@@ -50,0 +53,0 @@ if (matches && semverValid(matches[1])) { |
{ | ||
"name": "git-semver-tags", | ||
"version": "2.0.3", | ||
"version": "3.0.0", | ||
"description": "Get all git semver tags of your repository in reverse chronological order", | ||
@@ -44,3 +44,3 @@ "bugs": { | ||
}, | ||
"gitHead": "38f5508191f8afc1a8503d1fd24e2de6d05b8738" | ||
"gitHead": "dadbbf8b1acbe4b3a8f345633bde3f4a4ad0bea4" | ||
} |
@@ -17,4 +17,6 @@ # [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url] | ||
```js | ||
var gitSemverTags = require('git-semver-tags', [options]); | ||
var gitSemverTags = require('git-semver-tags'); | ||
// gitSemverTags([options,] callback) | ||
gitSemverTags(function(err, tags) { | ||
@@ -21,0 +23,0 @@ console.log(tags); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11448
78
55