-
Notifications
You must be signed in to change notification settings - Fork 11
/
install.ps1
42 lines (30 loc) · 1.28 KB
/
install.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
35
36
37
38
39
40
41
42
$ErrorActionPreference = 'Stop'
if ($Args.Length -eq 1) {
$Version = $Args.Get(0)
}
$BinDir = "${Home}\.nitrogen\bin"
$NitrogenTar = "$BinDir\nitrogen.tar.gz"
$NitrogenBin = "$BinDir\nitrogen.exe"
$Target = 'x86_64-pc-windows-msvc'
$DownloadUrl = if (!$Version) {
$RedirectUrl = curl.exe -s -L -I -o nul -w '%{url_effective}' "https://github.com/capeprivacy/nitrogen/releases/latest/download"
$Splits = $RedirectUrl.Split("/")
$Version = $Splits.Get($Splits.Length - 1)
"https://github.com/capeprivacy/nitrogen/releases/latest/download/nitrogen_${Version}_${Target}.tar.gz"
} else {
"https://github.com/capeprivacy/nitrogen/releases/download/${Version}/nitrogen_${Version}_${Target}.tar.gz"
}
if (!(Test-Path $BinDir)) {
New-Item $BinDir -ItemType Directory | Out-Null
}
curl.exe -Lo $NitrogenTar $DownloadUrl
tar.exe xf $NitrogenTar -C $BinDir
Remove-Item $NitrogenTar
$User = [System.EnvironmentVariableTarget]::User
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
if (!(";${Path};".ToLower() -like "*;${BinDir};*".ToLower())) {
[System.Environment]::SetEnvironmentVariable('Path', "${Path};${BinDir}", $User)
$Env:Path += ";${BinDir}"
}
Write-Output "Nitrogen was installed successfully to ${NitrogenBin}"
Write-Output "Run 'nitrogen --help' to get started"