| author | |
| committer | |
| log | 6d35a87c5d0e6dcf16be5b1d9a236a1d5e12c8c7 |
| tree | 95da707102232141b3b5e9b46979ca7fd16b3700 |
| parent | 7b9eef7ac29f9d4819c6411dfb1c5f04fef50264 |
| signature | Signed by PGP key B5690EEEBB952194 |
2 files changed, 34 insertions(+), 7 deletions(-)
apps/desktop/scripts/electron-launcher.mjs+13-6| ... | ... | @@ -358,10 +358,7 @@ function resolveLinuxSandboxArgs(electronBinaryPath) { |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | export function resolveElectronPath() { |
| 361 | ensureElectronRuntime(); | |
| 362 | ||
| 363 | const require = NodeModule.createRequire(import.meta.url); | |
| 364 | const electronBinaryPath = require("electron"); | |
| 361 | const electronBinaryPath = resolveElectronBinaryPath(); | |
| 365 | 362 | |
| 366 | 363 | if (hostPlatform !== "darwin") { |
| 367 | 364 | return electronBinaryPath; |
| ... | ... | @@ -378,13 +375,23 @@ export function resolveElectronLaunchCommand(args = []) { |
| 378 | 375 | }; |
| 379 | 376 | } |
| 380 | 377 | |
| 378 | export function resolveElectronBinaryPath({ | |
| 379 | ensureRuntime = ensureElectronRuntime, | |
| 380 | createRequire = NodeModule.createRequire, | |
| 381 | moduleUrl = import.meta.url, | |
| 382 | } = {}) { | |
| 383 | ensureRuntime(); | |
| 384 | ||
| 385 | const require = createRequire(moduleUrl); | |
| 386 | return require("electron"); | |
| 387 | } | |
| 388 | ||
| 381 | 389 | export function resolveDevProtocolClient() { |
| 382 | 390 | if (hostPlatform !== "darwin" || !isDevelopment) { |
| 383 | 391 | return null; |
| 384 | 392 | } |
| 385 | 393 | |
| 386 | const require = NodeModule.createRequire(import.meta.url); | |
| 387 | const electronBinaryPath = require("electron"); | |
| 394 | const electronBinaryPath = resolveElectronBinaryPath(); | |
| 388 | 395 | const launcherBinaryPath = buildMacLauncher(electronBinaryPath); |
| 389 | 396 | return { |
| 390 | 397 | appBundlePath: NodePath.resolve(launcherBinaryPath, "..", "..", ".."), |
apps/desktop/scripts/electron-launcher.test.mjs+21-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | import { assert, describe, it } from "vite-plus/test"; |
| 2 | 2 | |
| 3 | import { makeDevelopmentLauncherScript } from "./electron-launcher.mjs"; | |
| 3 | import { makeDevelopmentLauncherScript, resolveElectronBinaryPath } from "./electron-launcher.mjs"; | |
| 4 | 4 | |
| 5 | 5 | describe("electron development launcher", () => { |
| 6 | 6 | it("uses captured values only as fallbacks for a live runner environment", () => { |
| ... | ... | @@ -25,4 +25,24 @@ describe("electron development launcher", () => { |
| 25 | 25 | "exec '/repo/node_modules/electron/Electron' --t3code-dev-root='/repo/apps/desktop' '/repo/apps/desktop/dist-electron/main.cjs' \"$@\"", |
| 26 | 26 | ); |
| 27 | 27 | }); |
| 28 | ||
| 29 | it("repairs Electron before loading the package entrypoint", () => { | |
| 30 | const calls = []; | |
| 31 | const electronPath = resolveElectronBinaryPath({ | |
| 32 | ensureRuntime: () => { | |
| 33 | calls.push("ensure"); | |
| 34 | }, | |
| 35 | createRequire: () => (specifier) => { | |
| 36 | calls.push(`require:${specifier}`); | |
| 37 | return "/repo/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron"; | |
| 38 | }, | |
| 39 | moduleUrl: import.meta.url, | |
| 40 | }); | |
| 41 | ||
| 42 | assert.equal( | |
| 43 | electronPath, | |
| 44 | "/repo/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron", | |
| 45 | ); | |
| 46 | assert.deepEqual(calls, ["ensure", "require:electron"]); | |
| 47 | }); | |
| 28 | 48 | }); |