-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(electron, backend): coordinate Electron auto-updates via IPC and…
… install with visible installer Closes #256
- Loading branch information
1 parent
87b6f90
commit ac0373d
Showing
3 changed files
with
64 additions
and
30 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
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,32 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { app } from 'electron' | ||
import { autoUpdater } from 'electron-updater' | ||
|
||
import logger from '../lib/logger' | ||
|
||
export const initUpdates = server => { | ||
autoUpdater.logger = logger | ||
autoUpdater.autoInstallOnAppQuit = false | ||
|
||
autoUpdater.on( 'update-available', info => server.send( { event: 'update-available', payload: info } ) ) | ||
|
||
autoUpdater.on( 'update-downloaded', info => { | ||
server.send( { event: 'update-downloaded', payload: info } ) | ||
|
||
//* Override app handler to visually show installer | ||
app.on( 'will-quit', event => { | ||
event.preventDefault() | ||
autoUpdater.quitAndInstall( false, false ) | ||
} ) | ||
} ) | ||
} | ||
|
||
export const checkUpdates = async server => { | ||
logger.info( 'Checking for app updates, beta:', autoUpdater.allowPrerelease ) | ||
|
||
await autoUpdater.checkForUpdates().catch( logger.error ) | ||
|
||
server.send( { event: 'update-checked' } ) | ||
} | ||
|
||
export const setBeta = beta => { autoUpdater.allowPrerelease = beta } |
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