Skip to content

Commit

Permalink
fix: use semver to parse pre-release (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Apr 14, 2024
1 parent fdb515f commit e3f0e85
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"convert-gitmoji": "0.1.3",
"execa": "^8.0.1",
"kolorist": "^1.8.0",
"ofetch": "^1.3.4"
"ofetch": "^1.3.4",
"semver": "^7.6.0"
},
"devDependencies": {
"@antfu/eslint-config": "^2.9.0",
Expand Down
41 changes: 18 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/git.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import semver from 'semver'

export async function getGitHubRepo(baseUrl: string) {
const url = await execCommand('git', ['config', '--get', 'remote.origin.url'])
const escapedBaseUrl = baseUrl.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
Expand All @@ -22,8 +24,8 @@ export async function getGitTags() {
}

export async function getLastMatchingTag(inputTag: string) {
const isVersion = inputTag[0] === 'v'
const isPrerelease = inputTag[0] === 'v' && inputTag.includes('-')
const isVersion = semver.valid(semver.coerce(inputTag))
const isPrerelease = semver.prerelease(inputTag) !== null
const tags = await getGitTags()

let tag: string | undefined
Expand Down

0 comments on commit e3f0e85

Please sign in to comment.