From e48ab4dd20fffb6ea31cafd52ca4d1f66687b0e6 Mon Sep 17 00:00:00 2001 From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Date: Mon, 6 Jul 2026 23:12:54 -0400 Subject: [PATCH] fix(daemon): decompose win-unpacked layout paths with win32 semantics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit buildDaemonHostManifest processes Windows packaged-layout source paths, but used ambient node:path — so its unit test (which feeds hardcoded C:\ paths) produced wrong destRels on the Linux CI verify runner, where \ is not a separator. Use path.win32 for the pure relative/dirname decomposition (win32 accepts both / and \ and understands drive letters, so it's correct for Windows AND POSIX inputs), while keeping ambient join/dirname for every path that touches the real filesystem so the materialize tests stay host-native on Linux. Win32 runtime behavior is unchanged (path === path.win32 there). --- src/main/daemon/daemon-host-relocation.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/daemon/daemon-host-relocation.ts b/src/main/daemon/daemon-host-relocation.ts index 6a6eb242c..7b3f35da7 100644 --- a/src/main/daemon/daemon-host-relocation.ts +++ b/src/main/daemon/daemon-host-relocation.ts @@ -9,7 +9,7 @@ import { rmSync, writeFileSync } from 'node:fs' -import { dirname, join, relative, sep } from 'node:path' +import { dirname, join, win32 as winPath } from 'node:path' import { app } from 'electron' import { parseDaemonPidFile, startTimeMatches } from './daemon-health' @@ -79,8 +79,11 @@ type MaterializeMarker = { entryRelPath: string } +// Uses win32 path semantics so Windows layout paths (drive letters, `\`) +// decompose correctly regardless of host OS — needed for cross-platform unit +// tests; production runs this on win32 only. function toPosixRelative(fromDir: string, absPath: string): string { - return relative(fromDir, absPath).split(sep).join('/') + return winPath.relative(fromDir, absPath).split(winPath.sep).join('/') } function destPath(root: string, destRel: string): string { @@ -109,7 +112,7 @@ function collectDaemonHostSources(): DaemonHostSources | null { return null } const execPath = process.execPath - const appDir = dirname(execPath) + const appDir = winPath.dirname(execPath) const entrySourcePath = resolveEntrySourcePath(resourcesPath) return { appDir, @@ -158,7 +161,7 @@ export function buildDaemonHostManifest( // Daemon bundle: entry + its sibling chunks/ + the unpacked out/package.json // (CJS/ESM loader resolution), mirrored verbatim. ops.push({ sourcePath: entrySourcePath, destRel: entryRelPath, kind: 'file' }) - const chunksDir = join(dirname(entrySourcePath), 'chunks') + const chunksDir = join(winPath.dirname(entrySourcePath), 'chunks') ops.push({ sourcePath: chunksDir, destRel: toPosixRelative(appDir, chunksDir),