mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-06 02:48:28 +00:00
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
This commit is contained in:
parent
704f2d2af4
commit
43a201c8d5
2 changed files with 4 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { existsSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
export async function runCli(args: string[], env: Record<string, string> = {}) {
|
||||
// Use Bun.which() to find bun in PATH, but verify it exists
|
||||
|
|
@ -7,7 +8,7 @@ export async function runCli(args: string[], env: Record<string, string> = {}) {
|
|||
|
||||
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'
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue