Skip to content

Commit

Permalink
fix: simplify get-tags algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Nov 8, 2019
1 parent 1317348 commit 00420a8
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/branches/get-tags.js
Expand Up @@ -14,15 +14,10 @@ module.exports = async ({cwd, env, options: {tagFormat}}, branches) => {
return pReduce(
branches,
async (branches, branch) => {
const branchTags = await Promise.all(
(await getTags(branch.name, {cwd, env}))
.map(tag => {
const [, version, channel] = tag.match(tagRegexp) || [];
return {gitTag: tag, version, channel};
})
.filter(({version}) => version && semver.valid(semver.clean(version)))
.map(async ({gitTag, ...rest}) => ({gitTag, ...rest}))
);
const branchTags = (await getTags(branch.name, {cwd, env})).reduce((tags, tag) => {
const [, version, channel] = tag.match(tagRegexp) || [];
return version && semver.valid(semver.clean(version)) ? [...tags, {gitTag: tag, version, channel}] : tags;
}, []);

debug('found tags for branch %s: %o', branch.name, branchTags);
return [...branches, {...branch, tags: branchTags}];
Expand Down

0 comments on commit 00420a8

Please sign in to comment.