fix: clarify install switching

This commit is contained in:
Peter Steinberger
2026-04-26 09:46:34 +01:00
parent aad7b678b0
commit 6f50253a4d
6 changed files with 67 additions and 19 deletions

View File

@@ -3,6 +3,7 @@
# Or: & ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -NoOnboard
param(
[ValidateSet("npm", "git")]
[string]$InstallMethod = "npm",
[string]$Tag = "latest",
[string]$GitDir = "$env:USERPROFILE\openclaw",
@@ -336,11 +337,13 @@ function Install-OpenClawGit {
if (!(Test-Path $wrapperDir)) {
New-Item -ItemType Directory -Path $wrapperDir -Force | Out-Null
}
$entryPath = Join-Path $RepoDir "dist\entry.js"
@"
@echo off
node "%~dp0..\openclaw\dist\entry.js" %*
node "$entryPath" %*
"@ | Out-File -FilePath "$wrapperDir\openclaw.cmd" -Encoding ASCII -Force
Add-ToPath -Path $wrapperDir
Write-Host "OpenClaw installed" -Level success
return $true
@@ -432,7 +435,12 @@ function Main {
if ($DryRun) {
Write-Host "[DRY RUN] Would install OpenClaw from git to $GitDir" -Level info
} else {
Install-OpenClawGit -RepoDir $GitDir -Update:(-not $NoGitUpdate)
try {
npm uninstall -g openclaw 2>$null | Out-Null
} catch { }
if (!(Install-OpenClawGit -RepoDir $GitDir -Update:(-not $NoGitUpdate))) {
return (Fail-Install)
}
}
} else {
# npm method
@@ -443,6 +451,11 @@ function Main {
if ($DryRun) {
Write-Host "[DRY RUN] Would install OpenClaw via npm ($((Resolve-PackageInstallSpec -Target $Tag)))" -Level info
} else {
$gitWrapper = "$env:USERPROFILE\.local\bin\openclaw.cmd"
if (Test-Path $gitWrapper) {
Remove-Item -Force $gitWrapper
Write-Host "Removed git wrapper (switching to npm)" -Level info
}
if (!(Install-OpenClawNpm -Target $Tag)) {
return (Fail-Install)
}