@@ -13,6 +13,7 @@ const fixPath = require('fix-path');
1313const MongoClient = require ( 'mongodb' ) . MongoClient ;
1414// Executing terminal commands using JS
1515const { exec } = require ( 'child_process' ) ;
16+ const { autoUpdater } = require ( 'electron-updater' ) ;
1617
1718// Add React extension for development
1819const { default : installExtension , REACT_DEVELOPER_TOOLS } = require ( 'electron-devtools-installer' ) ;
@@ -89,6 +90,9 @@ function createWindow() {
8990 // when you should delete the corresponding element.
9091 mainWindow = null
9192 } )
93+ mainWindow . once ( 'ready-to-show' , ( ) => {
94+ autoUpdater . checkForUpdatesAndNotify ( ) ;
95+ } ) ;
9296}
9397
9498// This method will be called when Electron has finished
@@ -121,7 +125,7 @@ if (!fs.existsSync(path.join(process.resourcesPath, "/schemafiles/"))) {
121125}
122126let testpath = path . join ( process . resourcesPath , "/schemafiles/qlens.json" )
123127
124- if ( process . resourcesPath !== 'win32' ) fixPath ( )
128+ if ( process . resourcesPath !== 'win32' ) fixPath ( ) ;
125129
126130ipcMain . on ( 'URI' , ( event , arg ) => {
127131
@@ -156,3 +160,14 @@ ipcMain.on('URI', (event, arg) => {
156160 }
157161 } )
158162} ) ;
163+
164+ autoUpdater . on ( 'update-available' , ( ) => {
165+ mainWindow . webContents . send ( 'update_available' ) ;
166+ } ) ;
167+ autoUpdater . on ( 'update-downloaded' , ( ) => {
168+ mainWindow . webContents . send ( 'update_downloaded' ) ;
169+ } ) ;
170+
171+ ipcMain . on ( 'restart_app' , ( ) => {
172+ autoUpdater . quitAndInstall ( ) ;
173+ } ) ;
0 commit comments