basic-electron-updater
Version:
A secure, cross-platform auto-update library for Electron Forge apps using GitHub Releases.
43 lines (42 loc) • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyLinuxUpdate = applyLinuxUpdate;
const child_process_1 = require("child_process");
const fs_1 = require("fs");
/**
* Launches the AppImage, .deb, .rpm, or .tar.gz installer.
*/
function applyLinuxUpdate(installerPath) {
return new Promise((resolve, reject) => {
// Make AppImage executable if needed
if (installerPath.toLowerCase().endsWith('.appimage')) {
(0, fs_1.chmod)(installerPath, 0o755, (chmodErr) => {
if (chmodErr)
return reject(chmodErr);
executeInstaller();
});
}
else {
executeInstaller();
}
function executeInstaller() {
const isPackageManager = installerPath.endsWith('.deb') || installerPath.endsWith('.rpm');
if (isPackageManager) {
// For package managers, we can't auto-install, just open the file
(0, child_process_1.execFile)("xdg-open", [installerPath], (err) => {
if (err)
return reject(err);
resolve();
});
}
else {
// For AppImage or other executables
(0, child_process_1.execFile)(installerPath, [], (err) => {
if (err)
return reject(err);
resolve();
});
}
}
});
}