Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions components/hoxay/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ New-Item -ItemType Directory -Force -Path $ReleasesDir, $LogDir | Out-Null
function Log($msg) { Write-Host "[hoxay] $msg" }
function Die($msg) { Write-Host "[hoxay] ERROR: $msg" -ForegroundColor Red; exit 1 }

# Stop a managed app that is running from a release directory. The build
# replaces the executable in place, so a running instance has to go first.
function Stop-ManagedApp {
$names = @("hoxay", "herdr-t3")
$running = Get-Process -Name $names -ErrorAction SilentlyContinue
if (-not $running) { return }
foreach ($p in $running) {
Log "stopping running $($p.ProcessName) (pid $($p.Id))"
try { $p.CloseMainWindow() | Out-Null } catch { }
}
for ($i = 0; $i -lt 25; $i++) {
if (-not (Get-Process -Name $names -ErrorAction SilentlyContinue)) { return }
Start-Sleep -Milliseconds 200
}
Get-Process -Name $names -ErrorAction SilentlyContinue | ForEach-Object {
Log "force stopping $($_.ProcessName) (pid $($_.Id))"
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
}
Start-Sleep -Seconds 1
}

if (-not $Ref) {
# Stable release tags only: a prerelease tag like v1.1.0-rc.1 would fail
# the [version] cast below and must never win auto-selection.
Expand Down Expand Up @@ -56,6 +77,14 @@ if (-not (Test-Path (Join-Path $target ".git"))) {
git -C $target checkout --quiet $Ref
if ($LASTEXITCODE -ne 0) { Die "git checkout $Ref failed in $target" }
$commit = (git -C $target rev-parse HEAD).Trim()

# The app runs from the release directory, so a running instance locks the
# executable the build replaces and electron-builder fails (observed on a
# real Windows host: `update.ps1` over a running install). The app owns no
# herdr session — panes, agents and workspaces live in herdr — so stopping
# it is safe.
Stop-ManagedApp

Log "building $name ($commit)"

# `mise install --locked` must see only the checkout's own mise.toml /
Expand Down