diff --git a/src/main/utils/shell-env/compute-unix-shell-environment.injectable.ts b/src/main/utils/shell-env/compute-unix-shell-environment.injectable.ts index 668fa95aea..90108f7029 100644 --- a/src/main/utils/shell-env/compute-unix-shell-environment.injectable.ts +++ b/src/main/utils/shell-env/compute-unix-shell-environment.injectable.ts @@ -9,10 +9,10 @@ import spawnInjectable from "../../child-process/spawn.injectable"; import randomUUIDInjectable from "../../crypto/random-uuid.injectable"; export interface UnixShellEnvOptions { - signal?: AbortSignal; + signal: AbortSignal; } -export type ComputeUnixShellEnvironment = (shell: string, opts?: UnixShellEnvOptions) => Promise; +export type ComputeUnixShellEnvironment = (shell: string, opts: UnixShellEnvOptions) => Promise; const computeUnixShellEnvironmentInjectable = getInjectable({ id: "compute-unix-shell-environment", @@ -46,7 +46,7 @@ const computeUnixShellEnvironmentInjectable = getInjectable({ }; }; - return async (shellPath, opts = {}) => { + return async (shellPath, opts) => { const runAsNode = process.env["ELECTRON_RUN_AS_NODE"]; const noAttach = process.env["ELECTRON_NO_ATTACH_CONSOLE"]; const env = { @@ -61,12 +61,11 @@ const computeUnixShellEnvironmentInjectable = getInjectable({ return new Promise((resolve, reject) => { const shellProcess = spawn(shellPath, shellArgs, { detached: true, + signal: opts.signal, env, }); const stdout: Buffer[] = []; - opts.signal?.addEventListener("abort", () => shellProcess.kill()); - shellProcess.stdout.on("data", b => stdout.push(b)); shellProcess.on("error", (err) => reject(err));