The autoUpdater enables an electron app to check the latest version and update itself automatically. 1
You can install autoUpdater via NPM or yarn:
npm install --save—dev electron-updater
or
yarn add electron-updater
In main .js file of electron, autoUpdater can be defined as follows:
// main.js
const { autoUpdater } = require("electron-updater");
autoUpdater.setFeedURL({
provider: "github",
host: "github.com",
owner: "{ username }",
repo: "{ repository }",
token: "{ token }",
});
checking-for-update:
Emit when checking update has started.
update-available:
Emit when there is an available update. If autoDownload = true, the update will be downloaded automatically. The event contains the version, releaseDate, releaseNotes, etc.
update-not-available:
Emit when there is no available update.
error:
Emit when there is an error.
download-progress:
Emit when downloading update has started. The event contains the download percentages.
update-downloaded:
Emit when the update has been downloaded. The event contains the version, releaseDate, releaseNotes, downloadFile, etc.
autoDownload defines whether to automatically download an update when it is found. If autoDownload = false, you should manually execute autoUpdater.downloadUpdate() after receiving update-available event.autoInstallOnAppQuit defines whether to automatically install a downloaded update on app quit. If autoInstallOnAppQuit = false, you should manually execute autoUpdater.quitAndInstall().options consists of provider, host, owner, repo, token, etc.update-downloaded has been emitted.