Skip to content

Commit 36fc3db

Browse files
committed
fix(auto-updater): Autoupdates to lower version with allowPrerelease=true using GitHub releases
Close #1497
1 parent d6f0c57 commit 36fc3db

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

docs/Auto Update.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ Emitted on progress. Only supported over Windows build, since `Squirrel.Mac` [do
330330
| --- | --- | --- |
331331
| autoDownload = <code>true</code>| <code>boolean</code> | <a name="AppUpdater-autoDownload"></a>Whether to automatically download an update when it is found. |
332332
| allowPrerelease| <code>boolean</code> | <a name="AppUpdater-allowPrerelease"></a>*GitHub provider only.* Whether to allow update to pre-release versions. Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`.<br><br>If `true`, downgrade will be allowed (`allowDowngrade` will be set to `true`). |
333-
| allowDowngrade| <code>boolean</code> | <a name="AppUpdater-allowDowngrade"></a>Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel). Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`. |
333+
| allowDowngrade| <code>boolean</code> | <a name="AppUpdater-allowDowngrade"></a>Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel). |
334334
| requestHeaders| <code>[RequestHeaders](electron-builder-http#RequestHeaders)</code> \| <code>null</code> | <a name="AppUpdater-requestHeaders"></a>The request headers. |
335335
| logger = <code>(&lt;any&gt;global).__test_app ? null : console</code>| <code>[Logger](#Logger)</code> \| <code>null</code> | <a name="AppUpdater-logger"></a>The logger. You can pass [electron-log](https://github.com/megahertz/electron-log), [winston](https://github.com/winstonjs/winston) or another logger with the following interface: `{ info(), warn(), error() }`. Set it to `null` if you would like to disable a logging feature. |
336336
| signals = <code>new UpdaterSignal(this)</code>| <code>[UpdaterSignal](#UpdaterSignal)</code> | <a name="AppUpdater-signals"></a>For type safety you can use signals, e.g. `autoUpdater.signals.updateDownloaded(() => {})` instead of `autoUpdater.on('update-available', () => {})` |

packages/electron-updater/src/AppUpdater.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export abstract class AppUpdater extends EventEmitter {
3838

3939
/**
4040
* Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel).
41-
* Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`.
41+
* @default false
4242
*/
4343
allowDowngrade = false
4444

@@ -117,8 +117,7 @@ export abstract class AppUpdater extends EventEmitter {
117117
throw new Error(`App version is not valid semver version: "${currentVersionString}`)
118118
}
119119

120-
this.allowDowngrade = hasPrereleaseComponents(this.currentVersion)
121-
this.allowPrerelease = this.allowDowngrade
120+
this.allowPrerelease = hasPrereleaseComponents(this.currentVersion)
122121

123122
if (options != null) {
124123
this.setFeedURL(options)

test/src/nsisUpdaterTest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ test("check updates - no versions at all", async () => {
4545

4646
async function testUpdateFromBintray(app: any) {
4747
const updater = new NsisUpdater(null, app)
48+
updater.allowDowngrade = true
4849
updater.updateConfigPath = await writeUpdateConfig(<BintrayOptions>{
4950
provider: "bintray",
5051
owner: "actperepo",

0 commit comments

Comments
 (0)