-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic updater [DON'T MERGE] (#84)
Check updates and log --------- Signed-off-by: marcopiraccini <[email protected]>
- Loading branch information
1 parent
0b8f463
commit 1f09f3f
Showing
6 changed files
with
85 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { dialog } from 'electron' | ||
import { autoUpdater } from 'electron-updater' | ||
import log from 'electron-log' | ||
|
||
let updater | ||
autoUpdater.autoDownload = false | ||
log.transports.console.level = 'info' | ||
autoUpdater.logger = log | ||
|
||
autoUpdater.on('error', (error) => { | ||
log.error(error) | ||
dialog.showErrorBox('Error: ', error == null ? 'unknown' : (error.stack || error).toString()) | ||
}) | ||
|
||
autoUpdater.on('update-available', async () => { | ||
log.info('Update available') | ||
const { response } = await dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Found Meraki Update', | ||
message: 'Found update, do you want update now?', | ||
buttons: ['Sure', 'No'] | ||
}) | ||
if (response === 0) { | ||
log.info('Downloading now...') | ||
autoUpdater.downloadUpdate() | ||
} else { | ||
updater.enabled = true | ||
updater = null | ||
} | ||
}) | ||
|
||
autoUpdater.on('update-not-available', () => { | ||
log.info('Update not available') | ||
dialog.showMessageBox({ | ||
title: 'No Updates', | ||
message: 'Current version is up-to-date.' | ||
}) | ||
updater.enabled = true | ||
updater = null | ||
}) | ||
|
||
autoUpdater.on('update-downloaded', async () => { | ||
log.info('Update downloaded') | ||
await dialog.showMessageBox({ | ||
title: 'Install Updates', | ||
message: 'Updates downloaded, application will quit to apply the update' | ||
}) | ||
autoUpdater.quitAndInstall() | ||
}) | ||
|
||
// export this to MenuItem click callback | ||
export function checkForUpdates (menuItem, focusedWindow, event) { | ||
updater = menuItem | ||
updater.enabled = false | ||
log.info('Checking for updates...') | ||
autoUpdater.checkForUpdates() | ||
log.info('Checking for updates...done') | ||
} |