From dcc6f599a20329888942e8bda2551f06b1622580 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 30 Mar 2017 11:43:58 -0700 Subject: [PATCH] Auto-update hourly --- main.js | 12 +++++++++++- package.json | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 6f84a0102..fb449f5e4 100644 --- a/main.js +++ b/main.js @@ -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 () { diff --git a/package.json b/package.json index 75971c739..0b06aa546 100644 --- a/package.json +++ b/package.json @@ -66,5 +66,8 @@ "publish": [ "github" ] + }, + "dependencies": { + "electron-updater": "^1.11.2" } }