electron-updater
Advanced tools
Comparing version 6.0.0-alpha.3 to 6.0.0-alpha.4
@@ -32,3 +32,3 @@ "use strict"; | ||
const provider = downloadUpdateOptions.updateInfoAndProvider.provider; | ||
const fileInfo = (0, Provider_1.findFile)(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), "AppImage"); | ||
const fileInfo = (0, Provider_1.findFile)(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), "AppImage", ["rpm", "deb"]); | ||
return this.executeDownload({ | ||
@@ -94,15 +94,11 @@ fileExtension: "AppImage", | ||
const env = { | ||
...process.env, | ||
APPIMAGE_SILENT_INSTALL: "true", | ||
}; | ||
if (options.isForceRunAfter) { | ||
(0, child_process_1.spawn)(destination, [], { | ||
detached: true, | ||
stdio: "ignore", | ||
env, | ||
}).unref(); | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
this.spawnLog(destination, [], env); | ||
} | ||
else { | ||
env.APPIMAGE_EXIT_AFTER_INSTALL = "true"; | ||
(0, child_process_1.execFileSync)(destination, [], { env }); | ||
(0, child_process_1.execFileSync)(destination, [], env); | ||
} | ||
@@ -109,0 +105,0 @@ return true; |
@@ -13,2 +13,10 @@ import { AllPublishOptions } from "builder-util-runtime"; | ||
protected addQuitHandler(): void; | ||
protected wrapSudo(): string; | ||
protected spawnSyncLog(cmd: string, args?: string[], env?: {}): string; | ||
/** | ||
* This handles both node 8 and node 10 way of emitting error when spawning a process | ||
* - node 8: Throws the error | ||
* - node 10: Emit the error(Need to listen with on) | ||
*/ | ||
protected spawnLog(cmd: string, args?: string[], env?: any): Promise<boolean>; | ||
} | ||
@@ -15,0 +23,0 @@ export interface InstallOptions { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BaseUpdater = void 0; | ||
const child_process_1 = require("child_process"); | ||
const AppUpdater_1 = require("./AppUpdater"); | ||
@@ -87,4 +88,58 @@ class BaseUpdater extends AppUpdater_1.AppUpdater { | ||
} | ||
wrapSudo() { | ||
const { name } = this.app; | ||
const installComment = `"${name} would like to update"`; | ||
const sudo = this.spawnSyncLog("which gksudo || which kdesudo || which pkexec || which beesu"); | ||
const command = [sudo]; | ||
if (/kdesudo/i.test(sudo)) { | ||
command.push("--comment", installComment); | ||
command.push("-c"); | ||
} | ||
else if (/gksudo/i.test(sudo)) { | ||
command.push("--message", installComment); | ||
} | ||
else if (/pkexec/i.test(sudo)) { | ||
command.push("--disable-internal-agent"); | ||
} | ||
return command.join(" "); | ||
} | ||
spawnSyncLog(cmd, args = [], env = {}) { | ||
this._logger.info(`Executing: ${cmd} with args: ${args}`); | ||
const response = (0, child_process_1.spawnSync)(cmd, args, { | ||
stdio: "pipe", | ||
env: { ...process.env, ...env }, | ||
encoding: "utf-8", | ||
shell: true, | ||
}); | ||
return response.stdout.trim(); | ||
} | ||
/** | ||
* This handles both node 8 and node 10 way of emitting error when spawning a process | ||
* - node 8: Throws the error | ||
* - node 10: Emit the error(Need to listen with on) | ||
*/ | ||
// https://github.com/electron-userland/electron-builder/issues/1129 | ||
// Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors | ||
async spawnLog(cmd, args = [], env = {}) { | ||
this._logger.info(`Executing: ${cmd} with args: ${args}`); | ||
return new Promise((resolve, reject) => { | ||
try { | ||
const p = (0, child_process_1.spawn)(cmd, args, { | ||
stdio: "pipe", | ||
env: { ...process.env, ...env }, | ||
detached: true, | ||
}); | ||
p.on("error", error => { | ||
reject(error); | ||
}); | ||
p.unref(); | ||
resolve(p.pid !== undefined); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
} | ||
exports.BaseUpdater = BaseUpdater; | ||
//# sourceMappingURL=BaseUpdater.js.map |
@@ -12,2 +12,4 @@ /// <reference types="node" /> | ||
export { AppImageUpdater } from "./AppImageUpdater"; | ||
export { DebUpdater } from "./DebUpdater"; | ||
export { RpmUpdater } from "./RpmUpdater"; | ||
export { MacUpdater } from "./MacUpdater"; | ||
@@ -14,0 +16,0 @@ export { NsisUpdater } from "./NsisUpdater"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.UpdaterSignal = exports.UPDATE_DOWNLOADED = exports.DOWNLOAD_PROGRESS = exports.NsisUpdater = exports.MacUpdater = exports.AppImageUpdater = exports.Provider = exports.CancellationToken = exports.NoOpLogger = exports.AppUpdater = void 0; | ||
exports.UpdaterSignal = exports.UPDATE_DOWNLOADED = exports.DOWNLOAD_PROGRESS = exports.NsisUpdater = exports.MacUpdater = exports.RpmUpdater = exports.DebUpdater = exports.AppImageUpdater = exports.Provider = exports.CancellationToken = exports.NoOpLogger = exports.AppUpdater = void 0; | ||
const builder_util_runtime_1 = require("builder-util-runtime"); | ||
Object.defineProperty(exports, "CancellationToken", { enumerable: true, get: function () { return builder_util_runtime_1.CancellationToken; } }); | ||
const fs_extra_1 = require("fs-extra"); | ||
const path = require("path"); | ||
var AppUpdater_1 = require("./AppUpdater"); | ||
@@ -13,2 +15,6 @@ Object.defineProperty(exports, "AppUpdater", { enumerable: true, get: function () { return AppUpdater_1.AppUpdater; } }); | ||
Object.defineProperty(exports, "AppImageUpdater", { enumerable: true, get: function () { return AppImageUpdater_1.AppImageUpdater; } }); | ||
var DebUpdater_1 = require("./DebUpdater"); | ||
Object.defineProperty(exports, "DebUpdater", { enumerable: true, get: function () { return DebUpdater_1.DebUpdater; } }); | ||
var RpmUpdater_1 = require("./RpmUpdater"); | ||
Object.defineProperty(exports, "RpmUpdater", { enumerable: true, get: function () { return RpmUpdater_1.RpmUpdater; } }); | ||
var MacUpdater_1 = require("./MacUpdater"); | ||
@@ -30,2 +36,24 @@ Object.defineProperty(exports, "MacUpdater", { enumerable: true, get: function () { return MacUpdater_1.MacUpdater; } }); | ||
_autoUpdater = new (require("./AppImageUpdater").AppImageUpdater)(); | ||
try { | ||
const identity = path.join(process.resourcesPath, "package-type"); | ||
if (!(0, fs_extra_1.existsSync)(identity)) { | ||
return _autoUpdater; | ||
} | ||
console.info("Checking for beta autoupdate feature for deb/rpm distributions"); | ||
const fileType = (0, fs_extra_1.readFileSync)(identity).toString().trim(); | ||
console.info("Found package-type:", fileType); | ||
switch (fileType) { | ||
case "deb": | ||
_autoUpdater = new (require("./DebUpdater").DebUpdater)(); | ||
break; | ||
case "rpm": | ||
_autoUpdater = new (require("./RpmUpdater").RpmUpdater)(); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
catch (error) { | ||
console.warn("Unable to detect 'package-type' for autoUpdater (beta rpm/deb support). If you'd like to expand support, please consider contributing to electron-builder", error.message); | ||
} | ||
} | ||
@@ -32,0 +60,0 @@ return _autoUpdater; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const builder_util_runtime_1 = require("builder-util-runtime"); | ||
const child_process_1 = require("child_process"); | ||
const path = require("path"); | ||
@@ -109,3 +108,3 @@ const BaseUpdater_1 = require("./BaseUpdater"); | ||
const callUsingElevation = () => { | ||
_spawn(path.join(process.resourcesPath, "elevate.exe"), [options.installerPath].concat(args)).catch((e) => this.dispatchError(e)); | ||
this.spawnLog(path.join(process.resourcesPath, "elevate.exe"), [options.installerPath].concat(args)).catch(e => this.dispatchError(e)); | ||
}; | ||
@@ -117,3 +116,3 @@ if (options.isAdminRightsRequired) { | ||
} | ||
_spawn(options.installerPath, args).catch((e) => { | ||
this.spawnLog(options.installerPath, args).catch((e) => { | ||
// https://github.com/electron-userland/electron-builder/issues/1129 | ||
@@ -207,27 +206,2 @@ // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors | ||
exports.NsisUpdater = NsisUpdater; | ||
/** | ||
* This handles both node 8 and node 10 way of emitting error when spawning a process | ||
* - node 8: Throws the error | ||
* - node 10: Emit the error(Need to listen with on) | ||
*/ | ||
async function _spawn(exe, args) { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
const process = (0, child_process_1.spawn)(exe, args, { | ||
detached: true, | ||
stdio: "ignore", | ||
}); | ||
process.on("error", error => { | ||
reject(error); | ||
}); | ||
process.unref(); | ||
if (process.pid !== undefined) { | ||
resolve(true); | ||
} | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
//# sourceMappingURL=NsisUpdater.js.map |
{ | ||
"name": "electron-updater", | ||
"version": "6.0.0-alpha.3", | ||
"version": "6.0.0-alpha.4", | ||
"description": "Cross platform updater for electron applications", | ||
@@ -5,0 +5,0 @@ "main": "out/main.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
442775
87
4037
24