Skip to content
Permalink
Browse files

fix(electron-updater): nsis one-click per-machine auto-updating fails…

… (Error: spawn [...].exe EACCES)

Close #3480, Close #3367
  • Loading branch information...
develar committed Nov 16, 2018
1 parent 0fa9096 commit cc63141ea818d379c277e69ac7df3391e18ae4bc
@@ -135,8 +135,10 @@ export class NsisTarget extends Target {
file: log.filePath(installerPath),
archs: Array.from(this.archs.keys()).map(it => Arch[it]).join(", "),
}
const isPerMachine = options.perMachine === true
if (!this.isPortable) {
logFields.oneClick = oneClick
logFields.perMachine = isPerMachine
}
log.info(logFields, "building")

@@ -149,7 +151,7 @@ export class NsisTarget extends Target {
UNINSTALL_APP_KEY: uninstallAppKey,
PRODUCT_NAME: appInfo.productName,
PRODUCT_FILENAME: appInfo.productFilename,
APP_FILENAME: getWindowsInstallationDirName(appInfo, !oneClick || options.perMachine === true),
APP_FILENAME: getWindowsInstallationDirName(appInfo, !oneClick || isPerMachine),
APP_DESCRIPTION: appInfo.description,
VERSION: appInfo.version,

@@ -264,7 +266,7 @@ export class NsisTarget extends Target {
updateInfo = await createBlockmap(installerPath, this, packager, safeArtifactName)
}

if (updateInfo != null && options.perMachine === true && oneClick) {
if (updateInfo != null && isPerMachine && oneClick) {
updateInfo.isAdminRightsRequired = true
}

@@ -134,7 +134,7 @@ class Collector {
const resolved = await BluebirdPromise.map(unresolved, it => {
return this.readChildPackage(it, parentNodeModulesDir, rootDependency)
.catch(e => {
if ((e as any).code === "ENOENT") {
if ((e as NodeJS.ErrnoException).code === "ENOENT") {
return null
}
else {
@@ -27,6 +27,6 @@ export function asArray<T>(v: null | undefined | T | Array<T>): Array<T> {

export function newError(message: string, code: string) {
const error = new Error(message);
(error as any).code = code
(error as NodeJS.ErrnoException).code = code
return error
}
@@ -321,7 +321,7 @@ export class InvalidConfigurationError extends Error {
constructor(message: string, code: string = "ERR_ELECTRON_BUILDER_INVALID_CONFIGURATION") {
super(message);

(this as any).code = code
(this as NodeJS.ErrnoException).code = code
}
}

@@ -117,12 +117,12 @@ export class NsisUpdater extends BaseUpdater {
}

_spawn(options.installerPath, args)
.catch(e => {
.catch((e: Error) => {
// 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
const errorCode = (e as any).code
const errorCode = (e as NodeJS.ErrnoException).code
this._logger.info(`Cannot run installer: error code: ${errorCode}, error message: "${e.message}", will be executed again using elevate if EACCES"`)
if (errorCode === "UNKNOWN" || errorCode.code === "EACCES") {
if (errorCode === "UNKNOWN" || errorCode === "EACCES") {
callUsingElevation()
}
else {
@@ -70,7 +70,7 @@ class Assertions {
m = result
}
else {
m = (actualError as any).code || actualError.message
m = (actualError as NodeJS.ErrnoException).code || actualError.message

if (m.includes("HttpError: ") && m.indexOf("\n") > 0) {
m = m.substring(0, m.indexOf("\n"))

0 comments on commit cc63141

Please sign in to comment.
You can’t perform that action at this time.