From 289d5417a24d293528175d70e470f4c15d3024a4 Mon Sep 17 00:00:00 2001 From: Subhas Dandapani Date: Sat, 24 Oct 2015 21:22:57 +0530 Subject: [PATCH] #2 Initial support for auto updater, next needs code signing --- lib/updater.js | 29 +++++++++++++++++++++++++++++ main.js | 6 ++++++ 2 files changed, 35 insertions(+) create mode 100644 lib/updater.js diff --git a/lib/updater.js b/lib/updater.js new file mode 100644 index 0000000..acffb36 --- /dev/null +++ b/lib/updater.js @@ -0,0 +1,29 @@ +'use strict' + +const autoUpdater = require('auto-updater') +const pkg = require('../package.json') +const autoUpdateUrl = `http://docker-menu-updater.herokuapp.com/v1/rdsubhas/docker-menu/${pkg.version}` + +autoUpdater.on('error', function () { + console.log('error', arguments) +}) + +autoUpdater.on('checking-for-update', function () { + console.log('checking-for-update', arguments) +}) + +autoUpdater.on('update-available', function () { + console.log('update-available', arguments) +}) + +autoUpdater.on('update-not-available', function () { + console.log('update-not-available', arguments) +}) + +autoUpdater.on('update-downloaded', function () { + console.log('update-downloaded', arguments) +}) + +autoUpdater.setFeedUrl(autoUpdateUrl) + +module.exports = autoUpdater diff --git a/main.js b/main.js index 5d3fed1..cf918b7 100644 --- a/main.js +++ b/main.js @@ -5,6 +5,7 @@ const ipc = require('ipc') const fixPath = require('fix-path') const Tray = require('tray') const Menu = require('./lib/menu') +const Updater = require('./lib/updater') // report crashes to the Electron project require('crash-reporter').start() @@ -24,4 +25,9 @@ app.on('ready', function () { ipc.on('app-quit', function () { app.quit() }) + + // Check for updates + if (process.env.NODE_ENV !== 'development') { + Updater.checkForUpdates() + } })