electron-updater
Advanced tools
Comparing version 1.12.0 to 1.13.0
@@ -107,9 +107,20 @@ "use strict"; | ||
class AppUpdater extends (_events || _load_events()).EventEmitter { | ||
constructor(options) { | ||
constructor(options, app) { | ||
super(); | ||
/** | ||
* Automatically download an update when it is found. | ||
* Whether to automatically download an update when it is found. | ||
*/ | ||
this.autoDownload = true; | ||
/** | ||
* *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`. | ||
* | ||
* If `true`, downgrade will be allowed (`allowDowngrade` will be set to `true`). | ||
*/ | ||
this.allowPrerelease = false; | ||
/** | ||
* 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`. | ||
*/ | ||
this.allowDowngrade = false; | ||
/** | ||
* 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() }`. | ||
@@ -129,4 +140,4 @@ * Set it to `null` if you would like to disable a logging feature. | ||
}); | ||
if (global.__test_app != null) { | ||
this.app = global.__test_app; | ||
if (app != null || global.__test_app != null) { | ||
this.app = app || global.__test_app; | ||
this.untilAppReady = (_bluebirdLst2 || _load_bluebirdLst2()).default.resolve(); | ||
@@ -150,2 +161,10 @@ } else { | ||
} | ||
const currentVersionString = this.app.getVersion(); | ||
this.currentVersion = (0, (_semver || _load_semver()).valid)(currentVersionString); | ||
if (this.currentVersion == null) { | ||
throw new Error(`App version is not valid semver version: "${currentVersionString}`); | ||
} | ||
const versionPrereleaseComponent = (0, (_semver || _load_semver()).prerelease)(this.currentVersion); | ||
this.allowDowngrade = versionPrereleaseComponent != null && versionPrereleaseComponent.length > 0; | ||
this.allowPrerelease = this.allowDowngrade; | ||
if (options != null) { | ||
@@ -224,11 +243,6 @@ this.setFeedURL(options); | ||
} | ||
const currentVersionString = _this2.app.getVersion(); | ||
const currentVersion = (0, (_semver || _load_semver()).valid)(currentVersionString); | ||
if (currentVersion == null) { | ||
throw new Error(`App version is not valid semver version: "${currentVersion}`); | ||
} | ||
if (!(0, (_semver || _load_semver()).gt)(latestVersion, currentVersion)) { | ||
if (_this2.allowDowngrade ? (0, (_semver || _load_semver()).eq)(latestVersion, _this2.currentVersion) : !(0, (_semver || _load_semver()).gt)(latestVersion, _this2.currentVersion)) { | ||
_this2.updateAvailable = false; | ||
if (_this2.logger != null) { | ||
_this2.logger.info(`Update for version ${currentVersionString} is not available (latest version: ${versionInfo.version})`); | ||
_this2.logger.info(`Update for version ${_this2.currentVersion} is not available (latest version: ${versionInfo.version}, downgrade is ${_this2.allowDowngrade ? "allowed" : "disallowed"}.`); | ||
} | ||
@@ -235,0 +249,0 @@ _this2.emit("update-not-available", versionInfo); |
@@ -159,6 +159,17 @@ declare module "electron-updater/out/api" { | ||
/** | ||
* Automatically download an update when it is found. | ||
* Whether to automatically download an update when it is found. | ||
*/ | ||
autoDownload: boolean | ||
/** | ||
* *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`. | ||
* | ||
* If `true`, downgrade will be allowed (`allowDowngrade` will be set to `true`). | ||
*/ | ||
allowPrerelease: boolean | ||
/** | ||
* 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`. | ||
*/ | ||
allowDowngrade: boolean | ||
/** | ||
* The request headers. | ||
@@ -185,3 +196,4 @@ */ | ||
private fileInfo | ||
constructor(options: PublishConfiguration | null | undefined) | ||
private currentVersion | ||
constructor(options: PublishConfiguration | null | undefined, app?: any) | ||
getFeedURL(): string | null | undefined | ||
@@ -246,3 +258,3 @@ /** | ||
private quitHandlerAdded | ||
constructor(options?: PublishConfiguration) | ||
constructor(options?: PublishConfiguration, app?: any) | ||
/** | ||
@@ -249,0 +261,0 @@ * Start downloading update manually. You can use this method if `autoDownload` option is set to `false`. |
@@ -63,4 +63,4 @@ "use strict"; | ||
class NsisUpdater extends (_AppUpdater || _load_AppUpdater()).AppUpdater { | ||
constructor(options) { | ||
super(options); | ||
constructor(options, app) { | ||
super(options, app); | ||
this.quitAndInstallCalled = false; | ||
@@ -67,0 +67,0 @@ this.quitHandlerAdded = false; |
{ | ||
"name": "electron-updater", | ||
"version": "1.12.0", | ||
"version": "1.13.0", | ||
"description": "Cross platform updater for electron applications", | ||
@@ -5,0 +5,0 @@ "main": "out/main.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130345
1355