mirror of
https://github.com/iflytek/skillhub.git
synced 2026-08-28 11:25:00 +00:00
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.
This commit is contained in:
parent
87dbf2686b
commit
704f2d2af4
2 changed files with 9 additions and 3 deletions
|
|
@ -1,6 +1,9 @@
|
|||
import { existsSync } from 'node:fs'
|
||||
|
||||
export async function runCli(args: string[], env: Record<string, string> = {}) {
|
||||
// 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],
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue