-
Notifications
You must be signed in to change notification settings - Fork 0
/
rt.ps1
34 lines (24 loc) · 1.03 KB
/
rt.ps1
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
#!/usr/bin/env pwsh
# Thanks to Moon for the original script:
# https://moonrepo.dev/
$DownloadUrl = "https://github.com/MoskalykA/rt/releases/latest/download/windows.zip"
$InstallDir = "${Home}\.rt"
$ArchivePath = "${InstallDir}\windows.zip"
$BinDir = "${InstallDir}\bin"
$BinPath = "${InstallDir}\rt.exe"
if (!(Test-Path $InstallDir)) {
New-Item $InstallDir -ItemType Directory | Out-Null
}
curl.exe -Lo $ArchivePath $DownloadUrl
Expand-Archive $ArchivePath -DestinationPath $BinDir
Remove-Item -Path $ArchivePath
# Windows doesn't support a "shared binaries" type of folder,
# so instead of symlinking, we add the install dir to $PATH.
$User = [System.EnvironmentVariableTarget]::User
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
if (!(";${Path};".ToLower() -like "*;${BinDir};*".ToLower())) {
[System.Environment]::SetEnvironmentVariable('Path', "${BinDir};${Path}", $User)
$Env:Path = "${BinDir};${Env:Path}"
}
Write-Output "Successfully installed rt to ${BinPath}"
Write-Output "Run 'rt --help' to get started!"