-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
48 lines (39 loc) · 1.49 KB
/
Copy pathinstall.ps1
File metadata and controls
48 lines (39 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# cpps installer for Windows
# Run: powershell -ExecutionPolicy Bypass -File install.ps1
$ErrorActionPreference = "Stop"
$InstallDir = "$env:USERPROFILE\.cpps\bin"
$BinaryName = "cpps.exe"
Write-Host ""
Write-Host " Installing cpps..." -ForegroundColor Cyan
Write-Host ""
# Build release binary
Write-Host " Building release binary..." -ForegroundColor Yellow
$ErrorActionPreference = "Continue"
cargo build --release 2>&1 | Out-Null
$ErrorActionPreference = "Stop"
if ($LASTEXITCODE -ne 0) {
Write-Host " Build failed. Run 'cargo build --release' manually to see errors." -ForegroundColor Red
exit 1
}
# Create install directory
if (-not (Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
# Copy binary
$source = "target\release\$BinaryName"
$dest = "$InstallDir\$BinaryName"
Copy-Item $source $dest -Force
Write-Host " Installed to: $dest" -ForegroundColor Green
# Add to PATH if not already there
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("Path", "$userPath;$InstallDir", "User")
Write-Host " Added $InstallDir to user PATH" -ForegroundColor Green
Write-Host ""
Write-Host " Restart your terminal for PATH changes to take effect." -ForegroundColor Yellow
} else {
Write-Host " PATH already configured." -ForegroundColor Green
}
Write-Host ""
Write-Host " Done! Run 'cpps --version' to verify." -ForegroundColor Cyan
Write-Host ""