Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard in GithubProvider custom channel breaks case of no prerelease versions #6809

Closed
blakebyrnes opened this issue Apr 21, 2022 · 2 comments · Fixed by #6814
Closed

Guard in GithubProvider custom channel breaks case of no prerelease versions #6809

blakebyrnes opened this issue Apr 21, 2022 · 2 comments · Fixed by #6814

Comments

@blakebyrnes
Copy link
Contributor

Whoops, seems there was an error in some code I suggested:

packages/electron-updater/src/providers/GitHubProvider.ts:76:63 - error TS2345: Argument of type 'string | number | null' is not assignable to parameter of type 'string'.
  Type 'null' is not assignable to type 'string'.

76           const isCustomChannel = !['alpha', 'beta'].includes(hrefChannel)

Since we don't care about number/null when comparing against alpha/beta, let's just wrap hrefChannel to be String(hrefChannel)

Originally posted by @mmaietta in #6505 (comment)

@blakebyrnes blakebyrnes changed the title Whoops, seems there was an error in some code I suggested: Guard in GithubProvider custom channel breaks case of no prerelease versions Apr 21, 2022
@blakebyrnes
Copy link
Contributor Author

blakebyrnes commented Apr 21, 2022

This ticket has a strange format. Sorry for that. I was trying to reference where this originated. There's an issue if you use the allowPrerelease feature of the GithubProvider that causes it to fail to find any github releases if the current version is not a prerelease.

const currentChannel = this.updater?.channel || String(semver.prerelease(this.updater.currentVersion)?.[0]) || null

The string wrap added above causes the || null to never occur. It evaluates to the string 'undefined'. The same string wrap was not added to the comparison a few lines below, so it fails to properly match the condition where there's no currentChannel.

const hrefChannel = semver.prerelease(hrefTag)?.[0] || null

Solution seems to be to just wrap the second option.

@mmaietta
Copy link
Collaborator

Can you please open a PR with the fix? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants