From 8dabf64b8f84975cf4eb016dcd23411ab0d4bf64 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Thu, 8 Aug 2024 11:27:04 +0800 Subject: [PATCH] fix: add custom `channel` in github provider (#8393) --- .changeset/clean-trainers-talk.md | 5 +++++ .../electron-updater/src/providers/GitHubProvider.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .changeset/clean-trainers-talk.md diff --git a/.changeset/clean-trainers-talk.md b/.changeset/clean-trainers-talk.md new file mode 100644 index 00000000000..833d616f7c7 --- /dev/null +++ b/.changeset/clean-trainers-talk.md @@ -0,0 +1,5 @@ +--- +"electron-updater": patch +--- + +add custom channel in github provider diff --git a/packages/electron-updater/src/providers/GitHubProvider.ts b/packages/electron-updater/src/providers/GitHubProvider.ts index 1b15b6ff71c..a91cf6be4ae 100644 --- a/packages/electron-updater/src/providers/GitHubProvider.ts +++ b/packages/electron-updater/src/providers/GitHubProvider.ts @@ -48,6 +48,11 @@ export class GitHubProvider extends BaseGitHubProvider { super(options, "github.com", runtimeOptions) } + private get channel(): string { + const result = this.updater.channel || this.options.channel + return result == null ? this.getDefaultChannelName() : this.getCustomChannelName(result) + } + async getLatestVersion(): Promise { const cancellationToken = new CancellationToken() @@ -136,7 +141,10 @@ export class GitHubProvider extends BaseGitHubProvider { } try { - const channel = this.updater.allowPrerelease ? this.getCustomChannelName(String(semver.prerelease(tag)?.[0] || "latest")) : this.getDefaultChannelName() + let channel = this.channel + if (this.updater.allowPrerelease && semver.prerelease(tag)?.[0]) { + channel = this.getCustomChannelName(String(semver.prerelease(tag)?.[0])) + } rawData = await fetchData(channel) } catch (e: any) { if (this.updater.allowPrerelease) {