hyper/app/auto-updater.js
Guillermo Rauch aaed99abac Reorg (#386)
* Step 1: move electorn into `app/`.

This is to comply with the suggested directory format of
`electron-builder`: https://github.com/electron-userland/electron-builder#two-packagejson-structure

* Step 2: add build directory with icon files for mac / windows

* Step 3: move all development (web) assets into main directory

* Step 4: add `build` namespace to dev `package.json`

* Step 5: move all dev dependencies into dev file and get rid of
old electron packagers in favor of `eletorn-builder`

* Step 6: target build inside `app/` as everything else is excluded at build time

* Step 7: remove old stuff!

* Step 8: update README

* turn off asar for `child_pty`
2016-07-24 10:59:21 -07:00

45 lines
1 KiB
JavaScript

const { autoUpdater } = require('electron');
const { version } = require('./package');
const notify = require('./notify'); // eslint-disable-line no-unused-vars
const ms = require('ms');
const FEED_URL = 'https://hyperterm-updates.now.sh/update/osx';
let isInit = false;
function init () {
autoUpdater.on('error', (err, msg) => {
console.error('Error fetching updates', msg + ' (' + err.stack + ')');
});
autoUpdater.setFeedURL(`${FEED_URL}/${version}`);
setTimeout(() => {
autoUpdater.checkForUpdates();
}, ms('10s'));
setInterval(() => {
autoUpdater.checkForUpdates();
}, ms('5m'));
isInit = true;
}
module.exports = function (win) {
if (!isInit) init();
const { rpc } = win;
const onupdate = (ev, releaseNotes, releaseName) => {
rpc.emit('update available', { releaseNotes, releaseName });
};
autoUpdater.on('update-downloaded', onupdate);
rpc.once('quit and install', () => {
autoUpdater.quitAndInstall();
});
win.on('close', () => {
autoUpdater.removeListener('update-downloaded', onupdate);
});
};