bingocode 1.1.138 → 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/bin/bingo-win.cjs
CHANGED
|
@@ -62,18 +62,18 @@ function resolveBunExe() {
|
|
|
62
62
|
if (process.env.BUN_PATH && fs.existsSync(process.env.BUN_PATH)) {
|
|
63
63
|
return process.env.BUN_PATH;
|
|
64
64
|
}
|
|
65
|
-
//
|
|
66
|
-
const homeBun = path.join(os.homedir(), '.bun', 'bin', 'bun.exe');
|
|
67
|
-
if (fs.existsSync(homeBun)) return homeBun;
|
|
68
|
-
// npm 全局目录 bun.exe
|
|
65
|
+
// npm install -g bun 的真实位置:{npm prefix -g}/node_modules/bun/bin/bun.exe
|
|
69
66
|
try {
|
|
70
67
|
const npmPrefix = spawnSync('npm', ['prefix', '-g'], { shell: true, encoding: 'utf-8' });
|
|
71
68
|
if (npmPrefix.status === 0) {
|
|
72
|
-
const npmBun = path.join(npmPrefix.stdout.trim(), 'bun.exe');
|
|
69
|
+
const npmBun = path.join(npmPrefix.stdout.trim(), 'node_modules', 'bun', 'bin', 'bun.exe');
|
|
73
70
|
if (fs.existsSync(npmBun)) return npmBun;
|
|
74
71
|
}
|
|
75
72
|
} catch (_) {}
|
|
76
|
-
//
|
|
73
|
+
// ~/.bun/bin/bun.exe(bun 官方安装脚本的位置)
|
|
74
|
+
const homeBun = path.join(os.homedir(), '.bun', 'bin', 'bun.exe');
|
|
75
|
+
if (fs.existsSync(homeBun)) return homeBun;
|
|
76
|
+
// where bun.exe(PATH 兜底搜索)
|
|
77
77
|
try {
|
|
78
78
|
const where = spawnSync('where', ['bun.exe'], { shell: true, encoding: 'utf-8' });
|
|
79
79
|
if (where.status === 0) {
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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> {
|