Reputation: 63
I am trying to use the auto update feature of the electron-builder, I have added listeners for update-not-available
and update-available
. If there are no new updates the update-not-available
event is triggered successfully but for some reason when a new version of my app is available the update-available
event is not being triggered, is there any way to check why the event is not being triggered or add logs to see if any error is occurring?
Below is my code for main.js
const { autoUpdater } = require("electron-updater");
...other imports
app.on('ready', () => {
//do this
//Check for updates.
autoUpdater.checkForUpdates();
}
autoUpdater.on("update-not-available", (info) => {
const dialogOpts = {
type: 'info',
buttons: ['Ok'],
title: 'Application Update',
message: "Yay",
detail: 'No new updates.'
}
dialog.showMessageBox(dialogOpts, (response) => {
});
});
autoUpdater.on("update-available", (info) => {
const dialogOpts = {
type: 'info',
buttons: ['Ok'],
title: 'Application Update',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version is being downloaded.'
}
dialog.showMessageBox(dialogOpts, (response) => {
});
})
autoUpdater.on("update-downloaded", (info) => {
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Application Update',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version has been downloaded. Restart the application to apply the updates.'
}
dialog.showMessageBox(dialogOpts, (response) => {
if (response === 0) autoUpdater.quitAndInstall()
});
});
Upvotes: 3
Views: 1855
Reputation: 63
I was able to get the reason for failure by running the executable from the command line. It was failing because of the below line
message: process.platform === 'win32' ? releaseNotes : releaseName,
Because the variables were undefined. It was fixed by changing the call back function arguments to include releaseName
and releaseNotes
like so
autoUpdater.on("update-available", (event, releaseNotes, releaseName) => {
As provided in the docs here.
Upvotes: 2