Skip to content

Commit

Permalink
Testing autoupdater
Browse files Browse the repository at this point in the history
  • Loading branch information
“Andre committed Aug 20, 2017
1 parent 01469ca commit 334be7a
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,60 @@ const path = require('path')
const url = require('url')

//updater 85243753a7031694ec6856ac439cdfccf19b1fc7
const autoUpdater = require("electron-updater").autoUpdater
const { dialog } = require('electron')
const { autoUpdater } = require('electron-updater')

let updater
autoUpdater.autoDownload = true

autoUpdater.on('error', (event, error) => {
dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString())
})

autoUpdater.on('update-available', () => {
dialog.showMessageBox({
type: 'info',
title: 'Found Updates',
message: 'Found updates, do you want update now?',
buttons: ['Sure', 'No']
}, (buttonIndex) => {
if (buttonIndex === 0) {
autoUpdater.downloadUpdate()
}
else {
updater.enabled = true
updater = null
}
})
})

autoUpdater.on('update-not-available', () => {
dialog.showMessageBox({
title: 'No Updates',
message: 'Current version is up-to-date.'
})
updater.enabled = true
updater = null
})

autoUpdater.on('update-downloaded', () => {
dialog.showMessageBox({
title: 'Install Updates',
message: 'Updates downloaded, application will be quit for update...'
}, () => {
setImmediate(() => autoUpdater.quitAndInstall())
})
})

// export this to MenuItem click callback
function checkForUpdates (menuItem, focusedWindow, event) {
updater = menuItem
updater.enabled = false
autoUpdater.checkForUpdates()
}
module.exports.checkForUpdates = checkForUpdates
////////////////////////
// end autoupdater

const isDev = require('electron-is-dev'); // this is required to check if the app is running in development mode.
const {appUpdater} = require('./autoupdater')
Expand Down

0 comments on commit 334be7a

Please sign in to comment.