basic-electron-updater
Version:
A secure, cross-platform auto-update library for Electron Forge apps using GitHub Releases.
31 lines (30 loc) • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyWindowsUpdate = applyWindowsUpdate;
const child_process_1 = require("child_process");
/**
* Launches the downloaded installer and exits the app.
* For NSIS/EXE installers, this will start the installer and quit the app.
* Most Windows installers (including Squirrel.Windows) should be launched without arguments.
*/
function applyWindowsUpdate(installerPath) {
return new Promise((resolve, reject) => {
// Launch the installer without any arguments
// Most Windows installers handle updates automatically when launched
(0, child_process_1.execFile)(installerPath, [], (err) => {
if (err)
return reject(err);
// Quit the Electron app after starting the installer
try {
const electron = require("electron");
if (electron.app) {
electron.app.quit();
}
}
catch {
// Not in Electron context, ignore
}
resolve();
});
});
}