mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(installer): complete literal paths and recovery guidance
This commit is contained in:
+16
-9
@@ -131,8 +131,13 @@ function Install-Binary {
|
||||
# The running daemon may come from another installation directory.
|
||||
# Use the downloaded CLI: older versions have broken Windows liveness checks.
|
||||
# Stop verifies daemon identity and uses the current BSK_HOME.
|
||||
# Fail closed for both new installs and replacements; never discard daemon metadata here.
|
||||
& $Source daemon stop
|
||||
if ($LASTEXITCODE -ne 0) { throw "could not stop bsk daemon; installation was not changed" }
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$daemonHome = if ($env:BSK_HOME) { $env:BSK_HOME } else { Join-Path $HOME ".bsk" }
|
||||
$daemonInfoPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath((Join-Path $daemonHome "daemon.json"))
|
||||
throw "could not stop bsk daemon; installation was not changed. Stop any running bsk daemon, remove '$daemonInfoPath', then retry the installer."
|
||||
}
|
||||
if ([System.IO.File]::Exists($Target)) {
|
||||
# PowerShell 5.1 converts $null to an empty path for string parameters.
|
||||
[System.IO.File]::Replace($staged, $Target, [NullString]::Value)
|
||||
@@ -140,7 +145,6 @@ function Install-Binary {
|
||||
else {
|
||||
[System.IO.File]::Move($staged, $Target)
|
||||
}
|
||||
Write-Log "daemon will restart automatically on the next browser command"
|
||||
}
|
||||
finally {
|
||||
if ([System.IO.File]::Exists($staged)) { [System.IO.File]::Delete($staged) }
|
||||
@@ -193,13 +197,17 @@ function Main {
|
||||
}
|
||||
|
||||
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
|
||||
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
|
||||
[System.IO.Directory]::CreateDirectory($tempDir) | Out-Null
|
||||
|
||||
try {
|
||||
$archivePath = Join-Path $tempDir $archiveName
|
||||
|
||||
Write-Log "downloading ${downloadUrl}"
|
||||
Invoke-WebRequest -Uri $downloadUrl -OutFile $archivePath -UseBasicParsing -ErrorAction Stop
|
||||
# PowerShell 5.1's -OutFile treats brackets as wildcards. Write raw HTTP bytes literally.
|
||||
$response = Invoke-WebRequest -Uri $downloadUrl -UseBasicParsing -ErrorAction Stop
|
||||
try {
|
||||
[System.IO.File]::WriteAllBytes($archivePath, $response.RawContentStream.ToArray())
|
||||
} finally { $response.RawContentStream.Dispose() }
|
||||
|
||||
if ($expectedSha) {
|
||||
Write-Log "verifying checksum"
|
||||
@@ -221,9 +229,7 @@ function Main {
|
||||
Write-Die "bsk.exe not found in archive"
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $InstallDir)) {
|
||||
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
|
||||
}
|
||||
[System.IO.Directory]::CreateDirectory($InstallDir) | Out-Null
|
||||
|
||||
Install-Binary -Source (Join-Path $tempDir "bsk.exe") -Target (Join-Path $InstallDir "bsk.exe")
|
||||
|
||||
@@ -245,12 +251,13 @@ function Main {
|
||||
|
||||
$command = Get-Command bsk -ErrorAction SilentlyContinue
|
||||
if (-not $command -or $command.CommandType -ne "Application" -or $command.Source -ine $bskPath) {
|
||||
Write-Log "warning: 'bsk' does not resolve to $bskPath; check Get-Command bsk -All for a conflicting command"
|
||||
Write-Log "warning: 'bsk' does not resolve to $bskPath in this session; check Get-Command bsk -All for a conflicting command"
|
||||
}
|
||||
|
||||
Write-Log "done"
|
||||
Write-Host ""
|
||||
Write-Host "Open a new terminal (PowerShell / Git Bash) for PATH changes to take full effect."
|
||||
Write-Host "This PATH check covers the current session only; a new terminal may prefer a Machine PATH entry or alias."
|
||||
Write-Host "In a new PowerShell terminal, run Get-Command bsk -All and confirm the first result is $bskPath."
|
||||
}
|
||||
finally {
|
||||
Remove-Item -LiteralPath $tempDir -Recurse -Force -ErrorAction SilentlyContinue
|
||||
|
||||
Reference in New Issue
Block a user