-
Notifications
You must be signed in to change notification settings - Fork 7
/
install.ps1
49 lines (36 loc) · 1.19 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
43
44
45
46
47
48
49
#!/usr/bin/env pwsh
$ErrorActionPreference = 'Stop'
if ($v) {
$Version = "v${v}"
}
if ($Args.Length -eq 1) {
$Version = $Args.Get(0)
}
$CNDIInstall = $env:CNDI_INSTALL
$BinDir = if ($CNDIInstall) {
"${CNDIInstall}\bin"
} else {
"${Home}\.cndi\bin"
}
$CNDITarGz = "$BinDir\cndi.tar.gz"
$CNDIExe = "$BinDir\cndi.exe"
$DownloadUrl = if (!$Version) {
"https://github.com/polyseam/cndi/releases/latest/download/cndi-win.tar.gz"
} else {
"https://github.com/polyseam/cndi/releases/download/${Version}/cndi-win.tar.gz"
}
if (!(Test-Path $BinDir)) {
New-Item $BinDir -ItemType Directory | Out-Null
}
curl.exe --fail --location --progress-bar --output $CNDITarGz $DownloadUrl
tar.exe --extract --file $CNDITarGz -C $BinDir
Remove-Item $CNDITarGz
$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}"
}
& $CNDIExe '--help' '--welcome'
Write-Output "CNDI was installed successfully to ${CNDIExe}"
Write-Output "Stuck? Join our Discord https://cndi.run/di?utm_id=5095"