-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
47 lines (37 loc) · 1.37 KB
/
install.ps1
File metadata and controls
47 lines (37 loc) · 1.37 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
Write-Host "Installing xclock..."
# Check cargo
if (!(Get-Command cargo -ErrorAction SilentlyContinue)) {
Write-Error "Cargo not found. Please install Rust."
exit 1
}
$RepoUrl = "https://github.com/xscriptor/xclock.git"
$InstallDir = "$env:USERPROFILE\.cargo\bin"
# Check if we are in the repo
if (Test-Path "Cargo.toml") {
$Content = Get-Content "Cargo.toml" -Raw
if ($Content -match "xclock") {
Write-Host "Detected local repository. Building from source..."
cargo build --release
if (!(Test-Path $InstallDir)) {
New-Item -ItemType Directory -Force -Path $InstallDir
}
Copy-Item "target\release\xclock.exe" -Destination "$InstallDir\xclock.exe" -Force
Write-Host "Done! Ensure $InstallDir is in your PATH."
exit 0
}
}
$TempDir = [System.IO.Path]::GetTempPath() + "xclock_install"
if (Test-Path $TempDir) { Remove-Item -Recurse -Force $TempDir }
Write-Host "Cloning..."
git clone $RepoUrl $TempDir
Push-Location $TempDir
Write-Host "Building..."
cargo build --release
if (!(Test-Path $InstallDir)) {
New-Item -ItemType Directory -Force -Path $InstallDir
}
Write-Host "Copying to $InstallDir..."
Copy-Item "target\release\xclock.exe" -Destination "$InstallDir\xclock.exe" -Force
Write-Host "Done! Ensure $InstallDir is in your PATH."
Pop-Location
Remove-Item -Recurse -Force $TempDir