fix: 支持自定义 npm global 路径的 CLI 检测

- Linux 下使用 which 命令动态查找 openclaw
- 支持用户自定义 npm prefix 配置
- 修复 Issue #6

Closes #6
This commit is contained in:
晴天
2026-03-06 13:44:06 +08:00
parent 86142ac6e2
commit 7fbe918507

View File

@@ -283,10 +283,13 @@ const handlers = {
try { cliInstalled = fs.existsSync(path.join(process.env.APPDATA || '', 'npm', 'openclaw.cmd')) }
catch { cliInstalled = false }
} else {
// Linux
cliInstalled = fs.existsSync('/usr/bin/openclaw') ||
fs.existsSync('/usr/local/bin/openclaw') ||
fs.existsSync(path.join(homedir(), '.openclaw/bin/openclaw'))
// Linux - 使用 which 命令动态查找
try {
execSync('which openclaw', { stdio: 'pipe' })
cliInstalled = true
} catch {
cliInstalled = false
}
}
return [{ label, running, pid, description: 'OpenClaw Gateway', cli_installed: cliInstalled }]