Skip to content

Commit d6115bc

Browse files
authored
fix(electron-updater): fix backward compatibility for GitHub provider without channels (#6998)
1 parent c9f0da5 commit d6115bc

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

.changeset/fair-gifts-explain.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"electron-updater": patch
3+
---
4+
5+
fix(electron-updater): fix backward compatibility for GitHub provider without channels

packages/electron-updater/src/providers/GitHubProvider.ts

+31-25
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,38 @@ export class GitHubProvider extends BaseGitHubProvider<GithubUpdateInfo> {
5858
try {
5959
if (this.updater.allowPrerelease) {
6060
const currentChannel = this.updater?.channel || (semver.prerelease(this.updater.currentVersion)?.[0] as string) || null
61-
for (const element of feed.getElements("entry")) {
61+
62+
if (currentChannel === null) {
6263
// noinspection TypeScriptValidateJSTypes
63-
const hrefElement = hrefRegExp.exec(element.element("link").attribute("href"))!
64-
65-
// If this is null then something is wrong and skip this release
66-
if (hrefElement === null) continue
67-
68-
// This Release's Tag
69-
const hrefTag = hrefElement[1]
70-
//Get Channel from this release's tag
71-
const hrefChannel = (semver.prerelease(hrefTag)?.[0] as string) || null
72-
73-
const shouldFetchVersion = !currentChannel || ["alpha", "beta"].includes(currentChannel)
74-
const isCustomChannel = !["alpha", "beta"].includes(String(hrefChannel))
75-
// Allow moving from alpha to beta but not down
76-
const channelMismatch = currentChannel === "beta" && hrefChannel === "alpha"
77-
78-
if (shouldFetchVersion && !isCustomChannel && !channelMismatch) {
79-
tag = hrefTag
80-
break
81-
}
82-
83-
const isNextPreRelease = hrefChannel && hrefChannel === currentChannel
84-
if (isNextPreRelease) {
85-
tag = hrefTag
86-
break
64+
tag = hrefRegExp.exec(latestRelease.element("link").attribute("href"))![1]
65+
} else {
66+
for (const element of feed.getElements("entry")) {
67+
// noinspection TypeScriptValidateJSTypes
68+
const hrefElement = hrefRegExp.exec(element.element("link").attribute("href"))!
69+
70+
// If this is null then something is wrong and skip this release
71+
if (hrefElement === null) continue
72+
73+
// This Release's Tag
74+
const hrefTag = hrefElement[1]
75+
//Get Channel from this release's tag
76+
const hrefChannel = (semver.prerelease(hrefTag)?.[0] as string) || null
77+
78+
const shouldFetchVersion = !currentChannel || ["alpha", "beta"].includes(currentChannel)
79+
const isCustomChannel = !["alpha", "beta"].includes(String(hrefChannel))
80+
// Allow moving from alpha to beta but not down
81+
const channelMismatch = currentChannel === "beta" && hrefChannel === "alpha"
82+
83+
if (shouldFetchVersion && !isCustomChannel && !channelMismatch) {
84+
tag = hrefTag
85+
break
86+
}
87+
88+
const isNextPreRelease = hrefChannel && hrefChannel === currentChannel
89+
if (isNextPreRelease) {
90+
tag = hrefTag
91+
break
92+
}
8793
}
8894
}
8995
} else {

0 commit comments

Comments
 (0)