@samitouri / QOSami-HFS / commits / 648808b6

fix: CLI update without arguments shouldn't install previous beta if you are on latest beta

Massimo Melina committed Jun 7, 2024 at 12:18 UTC 648808b6f533aca7d5d15c19c653e57eb002fdb6
2 files changed +4 -4
src/commands.ts
+1 -1
@@ -102,7 +102,7 @@ const commands = {
102 'check-update': {
103 params: '',
104 async cb() {
105 - const update = _.find(await getUpdates(), x => x.isNewer)
105 + const update = (await getUpdates(true))[0]
106 if (!update)
107 throw "you already have the latest version: " + VERSION
108 console.log("new version available", update.name)
src/update.ts
+3 -3
@@ -24,14 +24,14 @@ interface Release {
24 isNewer: boolean // introduced by us
25 }
26
27 -export async function getUpdates() {
27 +export async function getUpdates(strict=false) {
28 const stable: Release = await getRepoInfo(HFS_REPO + '/releases/latest')
29 const verStable = ver(stable)
30 const ret = await getBetas()
31 stable.isNewer = currentVersion.olderThan(stable.tag_name)
32 if (stable.isNewer || RUNNING_BETA)
33 ret.push(stable)
34 - return ret
34 + return ret.filter(x => !strict || x.isNewer)
35
36 function ver(x: any) {
37 return versionToScalar(x.name)
@@ -77,7 +77,7 @@ export async function update(tagOrUrl: string='') {
77 if (!updateSource) {
78 if (/^\d/.test(tagOrUrl)) // work even if the tag is passed without the initial 'v' (useful for console commands)
79 tagOrUrl = 'v' + tagOrUrl
80 - const update = !tagOrUrl ? (await getUpdates())[0]
80 + const update = !tagOrUrl ? (await getUpdates(true))[0]
81 : await getRepoInfo(HFS_REPO + '/releases/tags/' + tagOrUrl).catch(e => {
82 if (e.message === '404') console.error("version not found")
83 else throw e