Auto-update hourly

This commit is contained in:
lilia 2017-03-30 11:43:58 -07:00 committed by Scott Nonnenberg
parent 6686621b0b
commit dcc6f599a2
No known key found for this signature in database
GPG Key ID: A4931C09644C654B
2 changed files with 14 additions and 1 deletions

12
main.js
View File

@ -6,6 +6,8 @@ const BrowserWindow = electron.BrowserWindow
const path = require('path')
const url = require('url')
const autoUpdater = require('electron-updater').autoUpdater
const autoUpdaterInterval = 60 * 60 * 1000;
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
@ -37,7 +39,15 @@ function createWindow () {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
app.on('ready', function() {
autoUpdater.addListener('update-downloaded', function() {
autoUpdater.quitAndInstall()
});
autoUpdater.checkForUpdates();
setInterval(function() { autoUpdater.checkForUpdates(); }, autoUpdaterInterval);
createWindow();
})
// Quit when all windows are closed.
app.on('window-all-closed', function () {

View File

@ -66,5 +66,8 @@
"publish": [
"github"
]
},
"dependencies": {
"electron-updater": "^1.11.2"
}
}