From 8bd662ea92514092a5c28a3f4cc2d43995c773cc Mon Sep 17 00:00:00 2001 From: yilsem Date: Sun, 11 Oct 2026 17:47:43 +0300 Subject: [PATCH] fix(desktop): download target Electron for cross-platform packaging --- apps/desktop/scripts/run-electron-builder.mjs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/desktop/scripts/run-electron-builder.mjs b/apps/desktop/scripts/run-electron-builder.mjs index 61a4242..d3e1645 100644 --- a/apps/desktop/scripts/run-electron-builder.mjs +++ b/apps/desktop/scripts/run-electron-builder.mjs @@ -36,7 +36,18 @@ function electronBuilderCli() { return path.join(path.dirname(pkgJson), rel) } -const dist = electronDistDir() +const cliArgs = process.argv.slice(2) +// An installed Electron dist belongs to the host. Cross-platform packaging +// must download the requested target instead of copying the host executable. +const crossPlatform = + (cliArgs.includes('--win') && process.platform !== 'win32') || + (cliArgs.includes('--mac') && process.platform !== 'darwin') || + (cliArgs.includes('--linux') && process.platform !== 'linux') +const crossArch = + (cliArgs.includes('--x64') && process.arch !== 'x64') || + (cliArgs.includes('--arm64') && process.arch !== 'arm64') || + (cliArgs.includes('--ia32') && process.arch !== 'ia32') +const dist = crossPlatform || crossArch ? null : electronDistDir() // Local `hermes desktop` builds only ever package (--dir or dist), never // publish a GitHub release — no CI workflow drives this script. But the npm // lifecycle env sets CI=1 (so esbuild's postinstall doesn't try interactive @@ -55,7 +66,7 @@ if (dist && fs.existsSync(distBinary(dist))) { "via @electron/get (electronVersion + ELECTRON_MIRROR)." ) } -args.push(...process.argv.slice(2)) +args.push(...cliArgs) const result = spawnSync(process.execPath, [electronBuilderCli(), ...args], { stdio: "inherit",