Move auto-updater-win to ES6
This commit is contained in:
parent
c730800f0c
commit
20e26a9639
1 changed files with 50 additions and 55 deletions
|
@ -1,33 +1,27 @@
|
|||
'use strict'
|
||||
|
||||
const app = require('electron').app
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
const {app} = require('electron')
|
||||
const {EventEmitter} = require('events')
|
||||
const squirrelUpdate = require('./squirrel-update-win')
|
||||
const util = require('util')
|
||||
|
||||
function AutoUpdater () {
|
||||
EventEmitter.call(this)
|
||||
}
|
||||
|
||||
util.inherits(AutoUpdater, EventEmitter)
|
||||
|
||||
AutoUpdater.prototype.quitAndInstall = function () {
|
||||
class AutoUpdater extends EventEmitter {
|
||||
quitAndInstall () {
|
||||
if (!this.updateAvailable) {
|
||||
return this.emitError('No update available, can\'t quit and install')
|
||||
}
|
||||
squirrelUpdate.processStart()
|
||||
return app.quit()
|
||||
}
|
||||
}
|
||||
|
||||
AutoUpdater.prototype.getFeedURL = function () {
|
||||
getFeedURL () {
|
||||
return this.updateURL
|
||||
}
|
||||
}
|
||||
|
||||
AutoUpdater.prototype.setFeedURL = function (updateURL, headers) {
|
||||
setFeedURL (updateURL, headers) {
|
||||
this.updateURL = updateURL
|
||||
}
|
||||
}
|
||||
|
||||
AutoUpdater.prototype.checkForUpdates = function () {
|
||||
checkForUpdates () {
|
||||
if (!this.updateURL) {
|
||||
return this.emitError('Update URL is not set')
|
||||
}
|
||||
|
@ -60,12 +54,13 @@ AutoUpdater.prototype.checkForUpdates = function () {
|
|||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Private: Emit both error object and message, this is to keep compatibility
|
||||
// with Old APIs.
|
||||
AutoUpdater.prototype.emitError = function (message) {
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new AutoUpdater()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue