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 }",
});
autoDownload = true
, the update will be downloaded automatically. The event contains the version, releaseDate, releaseNotes, 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.