-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
49 lines (36 loc) · 1.21 KB
/
install.ps1
File metadata and controls
49 lines (36 loc) · 1.21 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
49
#!/usr/bin/env pwsh
$ErrorActionPreference = 'Stop'
if ($v) {
$Version = "v${v}"
}
if ($Args.Length -eq 1) {
$Version = $Args.Get(0)
}
$CRONXInstall = $env:CRONX_INSTALL
$BinDir = if ($CRONXInstall) {
"${CRONXInstall}\bin"
} else {
"${Home}\.cronx\bin"
}
$CRONXTarGz = "$BinDir\cronx.tar.gz"
$CRONXExe = "$BinDir\cronx.exe"
$DownloadUrl = if (!$Version) {
"https://github.com/polyseam/cronx/releases/latest/download/cronx-win-amd64.tar.gz"
} else {
"https://github.com/polyseam/cronx/releases/download/${Version}/cronx-win-amd64.tar.gz"
}
if (!(Test-Path $BinDir)) {
New-Item $BinDir -ItemType Directory | Out-Null
}
curl.exe --fail --location --progress-bar --output $CRONXTarGz $DownloadUrl
tar.exe --extract --file $CRONXTarGz -C $BinDir
Remove-Item $CRONXTarGz
$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}"
}
& $CRONXExe '--help'
Write-Output "cronx was installed successfully to ${CRONXExe}"
Write-Output "Stuck? Join our Discord https://cronx.run/di?utm_id=5095"