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'