Skip to content

Commit

Permalink
Support semver target with gitTags package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
piranna committed Feb 9, 2024
1 parent f873346 commit 3951630
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/package-managers/gitTags.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** Fetches package metadata from Github tags. */
import parseGithubUrl from 'parse-github-url'
import remoteGitTags from 'remote-git-tags'
import semver from 'semver'
import { valid } from 'semver'
import { print } from '../lib/logging'
import * as versionUtil from '../lib/version-util'
import { GetVersion } from '../types/GetVersion'
Expand Down Expand Up @@ -42,7 +42,7 @@ const getSortedVersions = async (name: string, declaration: VersionSpec, options
.map(versionUtil.fixPseudoVersion)
// do not pass semver.valid reference directly since the mapping index will be interpreted as the loose option
// https://github.com/npm/node-semver#functions
.filter(tag => semver.valid(tag))
.filter(tag => valid(tag))
.sort(versionUtil.compareVersions)

return tags
Expand Down Expand Up @@ -85,6 +85,12 @@ export const greatestLevel =
export const minor = greatestLevel('minor')
export const patch = greatestLevel('patch')

/** semver is not possible on a remote Git URL, do nothing. */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const semver: GetVersion = async (_name: string, _declaration: VersionSpec, _options?: Options) => {
return { version: null }
}

// use greatest for newest rather than leaving newest undefined
// this allows a mix of npm and github urls to be used in a package file without causing an "Unsupported target" error
export const newest = greatest

0 comments on commit 3951630

Please sign in to comment.