Skip to content

Instantly share code, notes, and snippets.

@akashnimare
Last active December 30, 2016 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akashnimare/79c9105f7f9e9b4c97ccbdc971f8c3b6 to your computer and use it in GitHub Desktop.
Save akashnimare/79c9105f7f9e9b4c97ccbdc971f8c3b6 to your computer and use it in GitHub Desktop.
Adding auto-updates to electron apps
const electron = require('electron');
const {app} = require('electron');
const isDev = require('electron-is-dev'); // this is required to check if the app is running in development mode.
const {appUpdater} = require('./autoupdater');
/* Handling squirrel.windows events on windows
only required if you have build the windows with target squirrel. For NSIS target you don't need it. */
if (require('electron-squirrel-startup')) {
app.quit();
}
let mainWindow;
// Funtion to check the current OS. As of now there is no proper method to add auto-updates to linux platform.
function isWindowsOrmacOS() {
return process.platform === 'darwin' || process.platform === 'win32';
}
app.on('ready', () => {
mainWindow = new BrowserWindow({
height: 600,
width: 600
});
mainWindow.loadURL("https://github.com");
const page = mainWindow.webContents;
page.once('did-frame-finish-load', () => {
const checkOS = isWindowsOrmacOS();
if (checkOS && !isDev) {
// Initate auto-updates on macOs and windows
appUpdater();
}});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment