mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-17 04:33:36 +00:00
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
22 lines
786 B
TypeScript
22 lines
786 B
TypeScript
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
|
|
const whichBun = await Bun.which('bun')
|
|
const bunPath = (whichBun && existsSync(whichBun)) ? whichBun : process.execPath
|
|
|
|
const proc = Bun.spawn({
|
|
cmd: [bunPath, 'src/index.ts', ...args],
|
|
cwd: fileURLToPath(new URL('../../', import.meta.url)),
|
|
env: { ...process.env, ...env },
|
|
stdout: 'pipe',
|
|
stderr: 'pipe'
|
|
})
|
|
const [stdout, stderr, exitCode] = await Promise.all([
|
|
new Response(proc.stdout).text(),
|
|
new Response(proc.stderr).text(),
|
|
proc.exited
|
|
])
|
|
return { stdout: stdout.trim(), stderr: stderr.trim(), exitCode }
|
|
}
|