Use ES6 style class

This commit is contained in:
Kevin Sawicki 2016-01-15 14:12:57 -08:00
parent caf7cf5582
commit 02f055b784

View file

@ -1,25 +1,25 @@
'use strict';
const app = require('electron').app;
const EventEmitter = require('events').EventEmitter;
const url = require('url');
const squirrelUpdate = require('./squirrel-update-win');
const util = require('util');
function AutoUpdater() {
AutoUpdater.super_.call(this);
}
class AutoUpdater extends EventEmitter {
constructor() {
super();
}
util.inherits(AutoUpdater, EventEmitter);
AutoUpdater.prototype.quitAndInstall = function() {
quitAndInstall() {
squirrelUpdate.processStart();
return app.quit();
};
}
AutoUpdater.prototype.setFeedURL = function(updateURL) {
setFeedURL(updateURL) {
return this.updateURL = updateURL;
};
}
AutoUpdater.prototype.checkForUpdates = function() {
checkForUpdates() {
if (!this.updateURL) {
return this.emitError('Update URL is not set');
}
@ -52,12 +52,13 @@ AutoUpdater.prototype.checkForUpdates = function() {
});
};
})(this));
};
}
// 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;