From 49908fd81879b3a86e630ecebe66a4f7113ffa83 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 8 Aug 2016 13:03:02 -0700 Subject: [PATCH 1/3] Keep update available flag set until restart --- lib/browser/api/auto-updater/auto-updater-win.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/browser/api/auto-updater/auto-updater-win.js b/lib/browser/api/auto-updater/auto-updater-win.js index a010f76dd743..aeffc2cf8ba1 100644 --- a/lib/browser/api/auto-updater/auto-updater-win.js +++ b/lib/browser/api/auto-updater/auto-updater-win.js @@ -34,7 +34,6 @@ class AutoUpdater extends EventEmitter { return this.emitError(error) } if (update == null) { - this.updateAvailable = false return this.emit('update-not-available') } this.updateAvailable = true From dd6c69c90b1784ac76271efd9bb328a88044f874 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 8 Aug 2016 13:06:14 -0700 Subject: [PATCH 2/3] Use const instead of var --- lib/browser/api/auto-updater/auto-updater-win.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/browser/api/auto-updater/auto-updater-win.js b/lib/browser/api/auto-updater/auto-updater-win.js index aeffc2cf8ba1..55b8372f52cf 100644 --- a/lib/browser/api/auto-updater/auto-updater-win.js +++ b/lib/browser/api/auto-updater/auto-updater-win.js @@ -10,7 +10,7 @@ class AutoUpdater extends EventEmitter { return this.emitError('No update available, can\'t quit and install') } squirrelUpdate.processStart() - return app.quit() + app.quit() } getFeedURL () { @@ -39,15 +39,12 @@ class AutoUpdater extends EventEmitter { this.updateAvailable = true this.emit('update-available') squirrelUpdate.update(this.updateURL, (error) => { - var date, releaseNotes, version if (error != null) { return this.emitError(error) } - releaseNotes = update.releaseNotes - version = update.version - - // Following information is not available on Windows, so fake them. - date = new Date() + const {releaseNotes, version} = update + // Date is not available on Windows, so fake it. + const date = new Date() this.emit('update-downloaded', {}, releaseNotes, version, date, this.updateURL, () => { this.quitAndInstall() }) @@ -58,7 +55,7 @@ class AutoUpdater extends EventEmitter { // Private: Emit both error object and message, this is to keep compatibility // with Old APIs. emitError (message) { - return this.emit('error', new Error(message), message) + this.emit('error', new Error(message), message) } } From 07479579199b8e5a8c79ee8033cf66e41c8a4919 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 8 Aug 2016 13:12:39 -0700 Subject: [PATCH 3/3] Add spec for quitAndInstall with no update on Windows --- spec/api-auto-updater-spec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/api-auto-updater-spec.js b/spec/api-auto-updater-spec.js index f93590ccadd4..0716c2245df8 100644 --- a/spec/api-auto-updater-spec.js +++ b/spec/api-auto-updater-spec.js @@ -50,5 +50,19 @@ if (!process.mas) { done() }) }) + + describe('quitAndInstall', function () { + it('emits an error on Windows when no update is available', function (done) { + if (process.platform !== 'win32') { + return done() + } + + ipcRenderer.once('auto-updater-error', function (event, message) { + assert.equal(message, 'No update available, can\'t quit and install') + done() + }) + autoUpdater.quitAndInstall() + }) + }) }) }