bingocode 1.1.139 → 1.1.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bingocode",
3
- "version": "1.1.139",
3
+ "version": "1.1.140",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "claude": "bin/claude-win.cjs",
@@ -41,12 +41,42 @@
41
41
  }
42
42
  throw new Error(`Health check timeout: ${lastErr?.message || 'unknown'}`);
43
43
  }
44
- function resolveBunPath() {
44
+ function resolveBunPath(): string {
45
+ // 优先环境变量
45
46
  const fromEnv = process.env.BUN_PATH;
46
- if (fromEnv) return fromEnv;
47
- const r = spawnSync('bun', ['--version'], { stdio: 'ignore' });
48
- if (r.status === 0) return 'bun';
49
- throw new Error('Bun not detected. Please install https://bun.sh or set BUN_PATH');
47
+ if (fromEnv && fs.existsSync(fromEnv)) return fromEnv;
48
+
49
+ // Windows:查找真实 bun.exe 绝对路径,避免 spawn 'bun' ENOENT
50
+ if (process.platform === 'win32') {
51
+ // npm install -g bun 的真实位置:{npm prefix -g}/node_modules/bun/bin/bun.exe
52
+ try {
53
+ const npmPrefix = spawnSync('npm', ['prefix', '-g'], { shell: true, encoding: 'utf-8' });
54
+ if (npmPrefix.status === 0) {
55
+ const npmBun = path.join(npmPrefix.stdout.trim(), 'node_modules', 'bun', 'bin', 'bun.exe');
56
+ if (fs.existsSync(npmBun)) return npmBun;
57
+ }
58
+ } catch (_) {}
59
+ // ~/.bun/bin/bun.exe(bun 官方安装脚本位置)
60
+ const homeBun = path.join(os.homedir(), '.bun', 'bin', 'bun.exe');
61
+ if (fs.existsSync(homeBun)) return homeBun;
62
+ // where bun.exe 兜底
63
+ try {
64
+ const where = spawnSync('where', ['bun.exe'], { shell: true, encoding: 'utf-8' });
65
+ if (where.status === 0) {
66
+ const found = where.stdout.trim().split(/\r?\n/)[0];
67
+ if (found && fs.existsSync(found)) return found;
68
+ }
69
+ } catch (_) {}
70
+ } else {
71
+ // Linux/macOS:which bun
72
+ const r = spawnSync('which', ['bun'], { encoding: 'utf-8' });
73
+ if (r.status === 0) {
74
+ const found = r.stdout.trim();
75
+ if (found) return found;
76
+ }
77
+ }
78
+
79
+ throw new Error('Bun not detected. Please install via: npm install -g bun');
50
80
  }
51
81
 
52
82
  async function acquireLease(): Promise<string> {