fix: prefer bun.cmd over bun shell script on Windows

Windows npm installs both bun (shell script) and bun.cmd (batch file).
When spawning bun, cmd.exe cannot execute the shell script directly.
This change makes findBun() return the full path to bun.cmd on Windows.

Fixes: Stop hook "spawn bun ENOENT" on Windows
This commit is contained in:
Jarvis
2026-04-02 13:00:15 +08:00
parent 472d302133
commit 4d4b0a2f24
+7
View File
@@ -55,6 +55,13 @@ function findBun() {
});
if (pathCheck.status === 0 && pathCheck.stdout.trim()) {
// On Windows, prefer bun.cmd over bun (bun is a shell script, bun.cmd is the Windows batch file)
if (IS_WINDOWS) {
const bunCmdPath = pathCheck.stdout.split('\n').find(line => line.trim().endsWith('bun.cmd'));
if (bunCmdPath) {
return bunCmdPath.trim();
}
}
return 'bun'; // Found in PATH
}