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 b3d3d4abb5..bf10618310 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 randomUUIDInjectable from "../../crypto/random-uuid.injectable"; import { basename } from "path"; 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", @@ -45,7 +45,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 = { @@ -60,12 +60,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));