From c97f67ec4d897d6e11007dc4bed1af76e67fefd2 Mon Sep 17 00:00:00 2001 From: wiiiii123 Date: Sat, 11 Jul 2026 02:49:40 +0700 Subject: [PATCH] chore(ci): address quality review feedback --- .github/workflows/quality.yml | 5 +++++ electron/ipc/paths/binaries.test.ts | 8 ++++++++ electron/ipc/paths/binaries.ts | 26 +++++++++++--------------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 3b8169b8..45e5f651 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -47,6 +47,11 @@ jobs: if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: npm run lint + - name: Check formatting (advisory) + if: ${{ !cancelled() && steps.install.outcome == 'success' }} + continue-on-error: true + run: npm run format:check + - name: Test if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: npm test diff --git a/electron/ipc/paths/binaries.test.ts b/electron/ipc/paths/binaries.test.ts index 5b89d957..36186173 100644 --- a/electron/ipc/paths/binaries.test.ts +++ b/electron/ipc/paths/binaries.test.ts @@ -27,6 +27,14 @@ describe("Windows native helper path resolution", () => { await fs.rm(tempRoot, { recursive: true, force: true }); }); + it("resolves a requested platform tag independently of the host platform", async () => { + const { getNativeArchTag } = await import("./binaries"); + + expect(getNativeArchTag("win32")).toBe( + process.arch === "arm64" ? "win32-arm64" : "win32-x64", + ); + }); + it("prefers the branch-staged helper over a stale local CMake build in dev", async () => { const buildOutputPath = path.join( appPath, diff --git a/electron/ipc/paths/binaries.ts b/electron/ipc/paths/binaries.ts index a95a79cf..3e15f332 100644 --- a/electron/ipc/paths/binaries.ts +++ b/electron/ipc/paths/binaries.ts @@ -29,31 +29,33 @@ export function getNativeCaptureHelperSourcePath(): string { return resolveUnpackedAppPath("electron", "native", "ScreenCaptureKitRecorder.swift"); } -export function getNativeArchTag(): string { - if (process.platform === "darwin") { +export function getNativeArchTag(platform: NodeJS.Platform = process.platform): string { + if (platform === "darwin") { return process.arch === "arm64" ? "darwin-arm64" : "darwin-x64"; } - if (process.platform === "win32") { + if (platform === "win32") { return process.arch === "arm64" ? "win32-arm64" : "win32-x64"; } - if (process.platform === "linux") { + if (platform === "linux") { return process.arch === "arm64" ? "linux-arm64" : "linux-x64"; } - return `${process.platform}-${process.arch}`; + return `${platform}-${process.arch}`; } -export function getPrebundledNativeHelperPath(binaryName: string): string { - return resolveUnpackedAppPath("electron", "native", "bin", getNativeArchTag(), binaryName); +export function getPrebundledNativeHelperPath( + binaryName: string, + archTag = getNativeArchTag(), +): string { + return resolveUnpackedAppPath("electron", "native", "bin", archTag, binaryName); } export function resolvePreferredWindowsNativeHelperPath( helperDirectory: string, binaryName: string, ): string { - const windowsArchTag = process.arch === "arm64" ? "win32-arm64" : "win32-x64"; const buildOutputPath = resolveUnpackedAppPath( "electron", "native", @@ -62,13 +64,7 @@ export function resolvePreferredWindowsNativeHelperPath( "Release", binaryName, ); - const prebundledPath = resolveUnpackedAppPath( - "electron", - "native", - "bin", - windowsArchTag, - binaryName, - ); + const prebundledPath = getPrebundledNativeHelperPath(binaryName, getNativeArchTag("win32")); if (app.isPackaged && existsSync(prebundledPath)) { return prebundledPath;