From 704f2d2af4722ddea4fd943f3a496ead595cbfcb Mon Sep 17 00:00:00 2001 From: dongmucat <1127093059@qq.com> Date: Wed, 29 Apr 2026 16:08:53 +0800 Subject: [PATCH] fix(cli): verify Bun.which() path exists before using on Windows Bun.which('bun') on Windows CI returns a non-existent path (C:\Users\runneradmin\.bun\bin\bun.exe), causing all integration tests to fail. Add existsSync() check to fallback to process.execPath when the resolved path doesn't exist. Also fix version-command.test.ts to use process.execPath instead of hardcoded 'bun' string for cross-platform compatibility. Fixes 19 failing integration tests on Windows platform. --- cli/test/helpers/run-cli.ts | 7 +++++-- cli/test/integration/version-command.test.ts | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cli/test/helpers/run-cli.ts b/cli/test/helpers/run-cli.ts index 82c08945..28be2593 100644 --- a/cli/test/helpers/run-cli.ts +++ b/cli/test/helpers/run-cli.ts @@ -1,6 +1,9 @@ +import { existsSync } from 'node:fs' + export async function runCli(args: string[], env: Record = {}) { - // Use Bun.which() to find bun in PATH, fallback to current executable - const bunPath = await Bun.which('bun') || process.execPath + // 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], diff --git a/cli/test/integration/version-command.test.ts b/cli/test/integration/version-command.test.ts index 95b95e3f..838f5e1a 100644 --- a/cli/test/integration/version-command.test.ts +++ b/cli/test/integration/version-command.test.ts @@ -26,8 +26,11 @@ describe('version command', () => { const dir = await mkdtemp(join(tmpdir(), 'skillhub-node-build-')) const outfile = join(dir, 'index.js') await writeFile(join(dir, 'package.json'), JSON.stringify({ type: 'module' })) + + // Use process.execPath to ensure we use the current Bun executable + const bunPath = process.execPath const build = Bun.spawn({ - cmd: ['bun', 'build', 'src/index.ts', '--target=node', `--outfile=${outfile}`], + cmd: [bunPath, 'build', 'src/index.ts', '--target=node', `--outfile=${outfile}`], cwd: new URL('../../', import.meta.url).pathname, stdout: 'pipe', stderr: 'pipe'