From 43a201c8d5ea2cbd389b8d053aa0a0b51269165d Mon Sep 17 00:00:00 2001 From: dongmucat <1127093059@qq.com> Date: Wed, 29 Apr 2026 16:13:50 +0800 Subject: [PATCH] fix(cli): use fileURLToPath for cross-platform cwd path compatibility The issue was that new URL().pathname returns Unix-style paths on Windows (e.g., /D:/a/skillhub/...) which Bun.spawn() cannot resolve correctly. Using fileURLToPath() converts the URL to a proper platform-specific path. Changes: - cli/test/helpers/run-cli.ts: use fileURLToPath for cwd - cli/test/integration/version-command.test.ts: same fix for build spawn --- cli/test/helpers/run-cli.ts | 3 ++- cli/test/integration/version-command.test.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/test/helpers/run-cli.ts b/cli/test/helpers/run-cli.ts index 28be2593..c7f784f7 100644 --- a/cli/test/helpers/run-cli.ts +++ b/cli/test/helpers/run-cli.ts @@ -1,4 +1,5 @@ import { existsSync } from 'node:fs' +import { fileURLToPath } from 'node:url' export async function runCli(args: string[], env: Record = {}) { // Use Bun.which() to find bun in PATH, but verify it exists @@ -7,7 +8,7 @@ export async function runCli(args: string[], env: Record = {}) { const proc = Bun.spawn({ cmd: [bunPath, 'src/index.ts', ...args], - cwd: new URL('../../', import.meta.url).pathname, + cwd: fileURLToPath(new URL('../../', import.meta.url)), env: { ...process.env, ...env }, stdout: 'pipe', stderr: 'pipe' diff --git a/cli/test/integration/version-command.test.ts b/cli/test/integration/version-command.test.ts index 838f5e1a..c32851d9 100644 --- a/cli/test/integration/version-command.test.ts +++ b/cli/test/integration/version-command.test.ts @@ -2,6 +2,7 @@ import { describe, expect, test } from 'bun:test' import { mkdtemp, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' +import { fileURLToPath } from 'node:url' import { runCli } from '../helpers/run-cli' describe('version command', () => { @@ -31,7 +32,7 @@ describe('version command', () => { const bunPath = process.execPath const build = Bun.spawn({ cmd: [bunPath, 'build', 'src/index.ts', '--target=node', `--outfile=${outfile}`], - cwd: new URL('../../', import.meta.url).pathname, + cwd: fileURLToPath(new URL('../../', import.meta.url)), stdout: 'pipe', stderr: 'pipe' })