Security News
Internet Archive Hacked, 31 Million Record Compromised
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
electron-updater
Advanced tools
The electron-updater npm package provides a way to automatically update Electron applications. It integrates with the Electron framework to enable seamless updates of desktop applications built with Electron. The package allows for easy distribution of updates by checking for new versions and downloading them in the background.
Auto Update
This feature allows the application to automatically check for updates and notify the user when an update is available. It can also download and install the updates in the background.
const { autoUpdater } = require('electron-updater');
autoUpdater.checkForUpdatesAndNotify();
Update Events
This feature allows developers to listen for specific events during the update process, such as when an update is available or when it has been downloaded. Developers can then take appropriate actions, like prompting the user or automatically restarting the application.
const { autoUpdater } = require('electron-updater');
autoUpdater.on('update-available', (info) => {
console.log('Update available.');
});
autoUpdater.on('update-downloaded', (info) => {
console.log('Update downloaded; will install in 5 seconds');
setTimeout(() => {
autoUpdater.quitAndInstall();
}, 5000);
});
Manual Update Checks
This feature allows developers to manually trigger an update check instead of relying on automatic checks. This can be useful for giving users the option to check for updates on demand.
const { autoUpdater } = require('electron-updater');
autoUpdater.checkForUpdates();
A lightweight updater for Electron apps that works with GitHub Releases. It is simpler than electron-updater but does not provide as many configuration options or features such as differential updates.
A smart release server for Electron apps that uses GitHub as a backend for serving updates. It is not an npm package but a server that you can deploy. It provides similar functionality but requires more setup compared to electron-updater.
Squirrel is a set of tools for installing and updating Windows and macOS applications. While not an npm package, it is often used in conjunction with Electron to provide update functionality. It is more complex and provides more control over the update process compared to electron-updater.
Cross platform auto-updater for electron apps
There are two separate packages that make up the electron-updater
. The updater itself runs in your app's main process while the plugins project loads the plugins downloaded by the updater into the render process. If you don't use plugins, then you don't need the second project.
$ npm install electron-updater --save
$ npm install electron-plugins --save
See the electron-builder
project for creating installers for
various platforms.
See the sinopia
project for hosting your own npm packages.
electron
var app = require('app'),
ipc = require('ipc'),
util = require('util'),
BrowserWindow = require('browser-window'),
updater = require('electron-updater')
require('crash-reporter').start()
var mainWindow = null
app.on('window-all-closed', function() {
if (process.platform != 'darwin')
app.quit()
})
app.on('ready', function() {
// Instead of launching your window right away, start the updater
// to check to see if the app is valid or not.
// An app is invalid if any of its dependencies or plugins are missing.
// In this case the updater will begin a 'full' update. Once updated
// your app will be re-launched.
updater.on('ready', function () {
// This event is called if your app is currently valid.
// It may be out-of-date but it has all of the necessary
// dependencies and plugins to launch right now.
// Your app maybe also receive an update-available event following this
mainWindow = new BrowserWindow({width: 800, height: 600})
mainWindow.loadUrl('file://' + __dirname + '/index.html')
mainWindow.openDevTools({detach:true})
mainWindow.on('closed', function() {
mainWindow = null;
});
})
updater.on('updateRequired', function () {
// This event is fired if your app is not currently valid at startup.
// The app must be exited immediately and the auto-updater will be run instead.
// After the auto-update runs the app will be re-run.
app.quit();
})
updater.on('updateAvailable', function () {
// This event is fired after new versions of plugins have been downloaded and
// before the app and dependencies are downloaded. Plugins are installed side-by-side
// so they can be downloaded while the app is running.
// After the app is restarted it will watch for updates and fire the updated required
// event when newer versions are available.
if(mainWindow) {
// Send a message to your view(s)
mainWindow.webContents.send('update-available');
}
})
updater.start()
})
var plugins = require('electron-plugins'),
util = require('util'),
ipc = require('ipc')
document.addEventListener('DOMContentLoaded', function () {
var context = { document: document }
plugins.load(context, function (err, loaded) {
if(err) return console.error(err)
console.log('Plugins loaded successfully.')
})
})
ipc.on('update-available', function () {
console.log('there is an update available for download')
})
FAQs
Cross platform updater for electron applications
The npm package electron-updater receives a total of 161,853 weekly downloads. As such, electron-updater popularity was classified as popular.
We found that electron-updater demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
Security News
TC39 is meeting in Tokyo this week and they have approved nearly a dozen proposals to advance to the next stages.
Security News
Our threat research team breaks down two malicious npm packages designed to exploit developer trust, steal your data, and destroy data on your machine.