I have added this code to electron.js:
const { app, BrowserWindow, ipcMain, shell, dialog } = require('electron');
const { autoUpdater } = require("electron-updater");
autoUpdater.on("update-available", (_event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Ok'],
title: 'New version of KTaNEPad is available!',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version of KTaNEPad is available and being currently installed. It is recommended not to start a bomb while the update is installing as you might get another pop-up.'
};
dialog.showMessageBox(dialogOpts);
});
autoUpdater.on("update-downloaded", (_event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Update installed!',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version of KTaNEPad has been downloaded. Would you like to restart now or later?'
};
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if(returnValue.response === 0) autoUpdater.quitAndInstall();
});
});
I have added autoUpdater.checkForUpdates(); to the on ready function below createWindow().