From c51b61e8b95d61ad6af2991c86ce17ec2e727b1d Mon Sep 17 00:00:00 2001 From: Jack Lu <46274946+JackLuguibin@users.noreply.github.com> Date: Thu, 7 May 2026 23:09:13 +0800 Subject: [PATCH] fix(desktop): ensure Electron binary before predev via install.js --- packages/desktop/scripts/predev.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/desktop/scripts/predev.ts b/packages/desktop/scripts/predev.ts index 37c31d7eedb7..880a63ecf4c6 100644 --- a/packages/desktop/scripts/predev.ts +++ b/packages/desktop/scripts/predev.ts @@ -1,5 +1,25 @@ +import path from "node:path" +import { existsSync } from "node:fs" +import { fileURLToPath } from "node:url" import { $ } from "bun" +const desktopDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "..") +const electronDir = path.join(desktopDir, "node_modules", "electron") +if (!existsSync(path.join(electronDir, "path.txt"))) { + console.error("Electron OS binary missing; running electron postinstall (node install.js)...") + const proc = Bun.spawn(["node", "install.js"], { + cwd: electronDir, + stdout: "inherit", + stderr: "inherit", + stdin: "inherit", + }) + const code = await proc.exited + if (code !== 0) { + console.error("electron install.js exited with code", code) + process.exit(code ?? 1) + } +} + await $`bun ./scripts/copy-icons.ts ${process.env.OPENCODE_CHANNEL ?? "dev"}` await $`cd ../opencode && bun script/build-node.ts`