| 1 | import * as NodeChildProcess from "node:child_process"; |
| 2 | import * as NodePath from "node:path"; |
| 3 | |
| 4 | import { desktopDir, resolveElectronLaunchCommand } from "./electron-launcher.mjs"; |
| 5 | |
| 6 | NodeChildProcess.execFileSync( |
| 7 | process.execPath, |
| 8 | [NodePath.join(desktopDir, "scripts/build-browser-secret.mjs")], |
| 9 | { stdio: "inherit" }, |
| 10 | ); |
| 11 | |
| 12 | const childEnv = { ...process.env }; |
| 13 | delete childEnv.ELECTRON_RUN_AS_NODE; |
| 14 | |
| 15 | const electronCommand = resolveElectronLaunchCommand(["dist-electron/main.cjs"]); |
| 16 | const child = NodeChildProcess.spawn(electronCommand.electronPath, electronCommand.args, { |
| 17 | stdio: "inherit", |
| 18 | cwd: desktopDir, |
| 19 | env: childEnv, |
| 20 | }); |
| 21 | |
| 22 | child.on("exit", (code, signal) => { |
| 23 | if (signal) { |
| 24 | process.kill(process.pid, signal); |
| 25 | return; |
| 26 | } |
| 27 | process.exit(code ?? 0); |
| 28 | }); |