Progress event for electron-updater quitAndInstall method

318 Views Asked by At

Does electron-updater quitAndInstall() method emmit an installation progress event?

My client is asking for a progress bar while the update is installing but I don't see anything in the docs.

Note: I'm not referring to the update download progress (I already have that working).

Here is my code:

const { autoUpdater } = require("electron-updater");

const updater = (mainWindow) => {

  autoUpdater.checkForUpdates();

  autoUpdater.on("update-available", (data) => {
    mainWindow.webContents.send("update-available", data);
  });

  ipcMain.handle("download-update", (event) => {
    autoUpdater.downloadUpdate();
  });

  autoUpdater.on("download-progress", (data) => {
    logger.info(data);
    mainWindow.webContents.send("download-progress", data.percent);
  });

  autoUpdater.on("update-downloaded", (data) => {
    mainWindow.webContents.send("update-downloaded", data);
  });

  ipcMain.handle("install-and-restart", () => {
    // I'm looking for an installation progress event after I called this method.
    autoUpdater.quitAndInstall(false, true);
  });
};
1

There are 1 best solutions below

0
On

For showing installer progress event you can use "nsis" key in your package.json file. Add the following code in your package.json file:

"nsis": { "allowToChangeInstallationDirectory": true, "createDesktopShortcut": true, "oneClick": false }

Here "oneClick: false" does the magic. It tells whether to create one-click installer or assisted. By default the value is true, you can set the value to false to show a guided installation process.