dev: accept non-integer for beta version
Massimo Melina committed
Jul 27, 2023 at 12:25 UTC
53a17dcfea9741d21271bdfbf535f312000f7580
2 files changed
+4
-3
src/config.ts
+1
-1
@@ -48,7 +48,7 @@ if (!existsSync(filePath) && existsSync(legacyPosition))
48
// takes a semver like 1.2.3-alpha1, but alpha and beta numbers must share the number progression
49
export const versionToScalar = _.memoize((ver: string) => { // memoize so we don't have to care about converting same value twice
50
// this regexp is supposed to be resistant to optional leading "v" and an optional custom name after a space
51
- const res = /^v?(\d+)\.(\d+)\.(\d+)(?:-\w+(\d+))?/.exec(ver)
51
+ const res = /^v?(\d+)\.(\d+)\.(\d+)(?:-\D+([0-9.]+))?/.exec(ver)
52
if (!res) return NaN
53
const [,a,b,c,beta] = res.map(Number)
54
const officialScalar = c! + b! * 1E3 + a! * 1E6 // gives 3 digits for each number
src/update.ts
+3
-2
@@ -42,13 +42,14 @@ export async function getUpdates() {
42
const per = 100
43
const res: Release[] = await getRepoInfo(HFS_REPO + `/releases?per_page=${per}&page=${page++}`)
44
if (!res.length) break
45
+ const curV = currentVersion.getScalar()
46
for (const x of res) {
47
if (!x.prerelease) continue // prerelease are all the end
48
const v = ver(x)
49
if (v <= verStable) // prerelease-s are locally ordered, so as soon as we reach verStable we are done
50
return ret
50
- if (v === currentVersion.getScalar()) continue // skip current
51
- x.isNewer = v > currentVersion.getScalar() // make easy to know what's newer
51
+ if (v === curV) continue // skip current
52
+ x.isNewer = v > curV // make easy to know what's newer
53
ret.push(x)
54
}
55
}