first pass at standardizing; suite still passing!
This commit is contained in:
parent
f25c3d33b6
commit
4794385fac
30 changed files with 1454 additions and 1462 deletions
|
@ -1,61 +1,62 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
|
||||
const app = require('electron').app;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const squirrelUpdate = require('./squirrel-update-win');
|
||||
const util = require('util');
|
||||
const app = require('electron').app
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
const squirrelUpdate = require('./squirrel-update-win')
|
||||
const util = require('util')
|
||||
|
||||
function AutoUpdater() {
|
||||
EventEmitter.call(this);
|
||||
function AutoUpdater () {
|
||||
EventEmitter.call(this)
|
||||
}
|
||||
|
||||
util.inherits(AutoUpdater, EventEmitter);
|
||||
util.inherits(AutoUpdater, EventEmitter)
|
||||
|
||||
AutoUpdater.prototype.quitAndInstall = function() {
|
||||
squirrelUpdate.processStart();
|
||||
return app.quit();
|
||||
};
|
||||
AutoUpdater.prototype.quitAndInstall = function () {
|
||||
squirrelUpdate.processStart()
|
||||
return app.quit()
|
||||
}
|
||||
|
||||
AutoUpdater.prototype.setFeedURL = function(updateURL) {
|
||||
return this.updateURL = updateURL;
|
||||
};
|
||||
AutoUpdater.prototype.setFeedURL = function (updateURL) {
|
||||
this.updateURL = updateURL
|
||||
}
|
||||
|
||||
AutoUpdater.prototype.checkForUpdates = function() {
|
||||
AutoUpdater.prototype.checkForUpdates = function () {
|
||||
if (!this.updateURL) {
|
||||
return this.emitError('Update URL is not set');
|
||||
return this.emitError('Update URL is not set')
|
||||
}
|
||||
if (!squirrelUpdate.supported()) {
|
||||
return this.emitError('Can not find Squirrel');
|
||||
return this.emitError('Can not find Squirrel')
|
||||
}
|
||||
this.emit('checking-for-update');
|
||||
this.emit('checking-for-update')
|
||||
squirrelUpdate.download(this.updateURL, (error, update) => {
|
||||
if (error != null) {
|
||||
return this.emitError(error);
|
||||
return this.emitError(error)
|
||||
}
|
||||
if (update == null) {
|
||||
return this.emit('update-not-available');
|
||||
return this.emit('update-not-available')
|
||||
}
|
||||
this.emit('update-available');
|
||||
this.emit('update-available')
|
||||
squirrelUpdate.update(this.updateURL, (error) => {
|
||||
var date, releaseNotes, version;
|
||||
var date, releaseNotes, version
|
||||
if (error != null) {
|
||||
return this.emitError(error);
|
||||
return this.emitError(error)
|
||||
}
|
||||
releaseNotes = update.releaseNotes, version = update.version;
|
||||
releaseNotes = update.releaseNotes
|
||||
version = update.version
|
||||
|
||||
// Following information is not available on Windows, so fake them.
|
||||
date = new Date;
|
||||
date = new Date()
|
||||
this.emit('update-downloaded', {}, releaseNotes, version, date, this.updateURL, () => {
|
||||
this.quitAndInstall();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
this.quitAndInstall()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Private: Emit both error object and message, this is to keep compatibility
|
||||
// with Old APIs.
|
||||
AutoUpdater.prototype.emitError = function(message) {
|
||||
return this.emit('error', new Error(message), message);
|
||||
};
|
||||
AutoUpdater.prototype.emitError = function (message) {
|
||||
return this.emit('error', new Error(message), message)
|
||||
}
|
||||
|
||||
module.exports = new AutoUpdater;
|
||||
module.exports = new AutoUpdater()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue