mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
- Avoid placing EXE inside node_modules on Windows and WSL-on-NTFS - Add preinstall cleanup (global-only), limited to our EXE; age-guard stale .code-* dirs - Atomic cache writes with retries; mirror to node_modules only on Unix filesystems - Robust Windows unzip fallback chain (powershell.exe→powershell→pwsh→tar) - Detect WSL drvfs/cifs with realpath mount check; skip taskkill on WSL - Fallback to per-user cache if tmp staging dir is unavailable - Package windows-cleanup.ps1 and preinstall script
33 lines
1.2 KiB
PowerShell
33 lines
1.2 KiB
PowerShell
<#
|
|
Helper to recover from EBUSY/EPERM during global npm upgrades on Windows.
|
|
Closes running processes and removes stale package folders.
|
|
|
|
Usage (PowerShell):
|
|
Set-ExecutionPolicy -Scope Process Bypass -Force
|
|
./codex-cli/scripts/windows-cleanup.ps1
|
|
#>
|
|
|
|
$ErrorActionPreference = 'SilentlyContinue'
|
|
|
|
Write-Host "Stopping running Code/Coder processes..."
|
|
taskkill /IM code-x86_64-pc-windows-msvc.exe /F 2>$null | Out-Null
|
|
taskkill /IM code.exe /F 2>$null | Out-Null
|
|
taskkill /IM coder.exe /F 2>$null | Out-Null
|
|
|
|
Write-Host "Removing old global package (if present)..."
|
|
$npmRoot = (& npm root -g).Trim()
|
|
$pkgPath = Join-Path $npmRoot "@just-every\code"
|
|
if (Test-Path $pkgPath) {
|
|
try { Remove-Item -LiteralPath $pkgPath -Recurse -Force -ErrorAction Stop } catch {}
|
|
}
|
|
|
|
Write-Host "Removing temp staging directories (if present)..."
|
|
Get-ChildItem -LiteralPath (Join-Path $npmRoot "@just-every") -Force -ErrorAction SilentlyContinue |
|
|
Where-Object { $_.Name -like '.code-*' } |
|
|
ForEach-Object {
|
|
try { Remove-Item -LiteralPath $_.FullName -Recurse -Force -ErrorAction Stop } catch {}
|
|
}
|
|
|
|
Write-Host "Cleanup complete. You can now run: npm install -g @just-every/code@latest"
|
|
|