OpenAsar/src/updater/hostUpdater.js

25 lines
547 B
JavaScript
Raw Normal View History

const { app, autoUpdater } = require('electron');
2021-12-09 16:25:14 +00:00
const { get } = require('request');
2021-12-09 16:25:14 +00:00
module.exports = process.platform === 'linux' ? new (class HostLinux extends require('events').EventEmitter {
2021-12-09 16:25:14 +00:00
setFeedURL(url) {
this.url = url;
2021-12-09 16:25:14 +00:00
}
quitAndInstall() {
app.relaunch();
app.quit();
2021-12-09 16:25:14 +00:00
}
async checkForUpdates() {
get(this.url, (e, r) => {
if (e) return this.emit('error');
2021-12-09 16:25:14 +00:00
if (r.statusCode === 204) return this.emit('update-not-available');
2021-12-09 16:25:14 +00:00
this.emit('update-manually');
});
2021-12-09 16:25:14 +00:00
}
})() : autoUpdater;