Emit an error if quitAndInstall is called without an update being available

This commit is contained in:
Samuel Attard 2016-04-26 01:35:34 +10:00
parent 60b9ff3948
commit 315cd9d2c8
2 changed files with 22 additions and 4 deletions

View file

@ -12,6 +12,9 @@ function AutoUpdater () {
util.inherits(AutoUpdater, EventEmitter)
AutoUpdater.prototype.quitAndInstall = function () {
if (!this.updateAvailable) {
return this.emitError('No update available, can\'t quit and install')
}
squirrelUpdate.processStart()
return app.quit()
}
@ -33,8 +36,10 @@ AutoUpdater.prototype.checkForUpdates = function () {
return this.emitError(error)
}
if (update == null) {
this.updateAvailable = false
return this.emit('update-not-available')
}
this.updateAvailable = true
this.emit('update-available')
squirrelUpdate.update(this.updateURL, (error) => {
var date, releaseNotes, version