feat: china-first openclaw install (npmmirror fallback to npmjs)
This commit is contained in:
@@ -187,12 +187,27 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 3: 安装 / 更新 OpenClaw
|
||||
# 国内网络优先:npmmirror → npmjs(必要时)
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "正在安装 / 更新 OpenClaw..."
|
||||
|
||||
npm install -g openclaw@latest 2>&1 | Write-Host
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Err "OpenClaw 安装失败。请手动运行:npm install -g openclaw@latest"
|
||||
function Install-OpenClawByRegistry($registry) {
|
||||
Write-Info "尝试通过 npm 安装 OpenClaw($registry)..."
|
||||
npm install -g openclaw@latest --registry=$registry 2>&1 | Write-Host
|
||||
return ($LASTEXITCODE -eq 0)
|
||||
}
|
||||
|
||||
$installedOpenClaw = $false
|
||||
if (Install-OpenClawByRegistry "https://registry.npmmirror.com") {
|
||||
Write-Ok "已通过 npmmirror 安装 / 更新 OpenClaw。"
|
||||
$installedOpenClaw = $true
|
||||
} elseif (Install-OpenClawByRegistry "https://registry.npmjs.org") {
|
||||
Write-Ok "已通过 npm 官方源安装 / 更新 OpenClaw。"
|
||||
$installedOpenClaw = $true
|
||||
}
|
||||
|
||||
if (-not $installedOpenClaw) {
|
||||
Write-Err "OpenClaw 安装失败:npmmirror 与 npm 官方源均不可用。"
|
||||
}
|
||||
|
||||
# 刷新 PATH
|
||||
|
||||
Reference in New Issue
Block a user