From f6bd45c21446db0d78cb11bf96b8c17bd421cf86 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sat, 1 Aug 2026 22:12:58 +0100 Subject: [PATCH] Enhance core dependency management and CLI script for macOS - Updated ensure-electrobun-core.mjs to ensure core dependencies for both host and target architectures, improving compatibility. - Modified patch-electrobun-src.mjs to enhance the handling of the Bun binary, ensuring the correct binary is used based on availability, which improves error reporting and execution reliability. --- scripts/ensure-electrobun-core.mjs | 6 +++++- scripts/patch-electrobun-src.mjs | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/ensure-electrobun-core.mjs b/scripts/ensure-electrobun-core.mjs index cff2837..359a899 100644 --- a/scripts/ensure-electrobun-core.mjs +++ b/scripts/ensure-electrobun-core.mjs @@ -114,10 +114,14 @@ async function ensureCoreDependencies(targetOS, targetArch) { } const targetOS = "macos"; +const hostArch = getReleaseArch(process.arch); const targetArch = getReleaseArch( process.env.ELECTROBUN_TARGET_ARCH || process.env.ELECTROBUN_FORCE_ARCH || process.arch, ); -await ensureCoreDependencies(targetOS, targetArch); +const archesToEnsure = new Set([hostArch, targetArch]); +for (const arch of archesToEnsure) { + await ensureCoreDependencies(targetOS, arch); +} diff --git a/scripts/patch-electrobun-src.mjs b/scripts/patch-electrobun-src.mjs index 8e384b6..2d41d08 100644 --- a/scripts/patch-electrobun-src.mjs +++ b/scripts/patch-electrobun-src.mjs @@ -151,6 +151,25 @@ if (!cliSource.includes("toolPaths")) { "zigAsarCli = join(toolPaths.BSPATCH).replace(\"bspatch\", \"zig-asar\");", ); writeFileSync(cliPath, cliSource); + cliSource = readFileSync(cliPath, "utf8"); +} +if (!cliSource.includes("hookBunBinary")) { + cliSource = cliSource.replace( + `const hostPaths = getPlatformPaths(OS, HOST_ARCH); + + const result = Bun.spawnSync([hostPaths.BUN_BINARY, hookScript],`, + `const hostPaths = getPlatformPaths(OS, HOST_ARCH); + const hookBunBinary = existsSync(hostPaths.BUN_BINARY) + ? hostPaths.BUN_BINARY + : process.execPath; + + const result = Bun.spawnSync([hookBunBinary, hookScript],`, + ); + cliSource = cliSource.replace( + "console.error(\"Tried to run with bun at:\", hostPaths.BUN_BINARY);", + "console.error(\"Tried to run with bun at:\", hookBunBinary);", + ); + writeFileSync(cliPath, cliSource); } const markerPath = path.join(electrobunDir, ".farmcontrol-electrobun-patched");