Skip to content

Commit a2ab1ff

Browse files
authored
fix: NsisUpdater - only resolving true if pid !== undefined (#7503)
Fixes: #7502
1 parent 2602331 commit a2ab1ff

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

.changeset/famous-terms-crash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"electron-updater": patch
3+
---
4+
5+
fix: NsisUpdater - only resolving true if pid !== undefined

packages/electron-updater/src/AppImageUpdater.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ export class AppImageUpdater extends BaseUpdater {
9898
this.emit("appimage-filename-updated", destination)
9999
}
100100

101-
const env: any = {
101+
const env: NodeJS.ProcessEnv = {
102+
...process.env,
102103
APPIMAGE_SILENT_INSTALL: "true",
103104
}
104105

@@ -107,7 +108,7 @@ export class AppImageUpdater extends BaseUpdater {
107108
this.spawnLog(destination, [], env)
108109
} else {
109110
env.APPIMAGE_EXIT_AFTER_INSTALL = "true"
110-
execFileSync(destination, [], env)
111+
execFileSync(destination, [], { env })
111112
}
112113
return true
113114
}

packages/electron-updater/src/BaseUpdater.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AllPublishOptions } from "builder-util-runtime"
2-
import { spawn, spawnSync } from "child_process"
2+
import { spawn, SpawnOptions, spawnSync, StdioOptions } from "child_process"
33
import { AppAdapter } from "./AppAdapter"
44
import { AppUpdater, DownloadExecutorTask } from "./AppUpdater"
55

@@ -134,20 +134,19 @@ export abstract class BaseUpdater extends AppUpdater {
134134
*/
135135
// https://github.com/electron-userland/electron-builder/issues/1129
136136
// Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors
137-
protected async spawnLog(cmd: string, args: string[] = [], env: any = {}): Promise<boolean> {
137+
protected async spawnLog(cmd: string, args: string[] = [], env: any = undefined, stdio: StdioOptions = "ignore"): Promise<boolean> {
138138
this._logger.info(`Executing: ${cmd} with args: ${args}`)
139139
return new Promise<boolean>((resolve, reject) => {
140140
try {
141-
const p = spawn(cmd, args, {
142-
stdio: "inherit",
143-
env: { ...process.env, ...env },
144-
detached: true,
145-
})
141+
const params: SpawnOptions = { stdio, env, detached: true }
142+
const p = spawn(cmd, args, params)
146143
p.on("error", error => {
147144
reject(error)
148145
})
149146
p.unref()
150-
resolve(p.pid !== undefined)
147+
if (process.pid !== undefined) {
148+
resolve(true)
149+
}
151150
} catch (error) {
152151
reject(error)
153152
}

0 commit comments

Comments
 (0)