forked from whalebrew/whalebrew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
38 lines (30 loc) · 1.53 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
# Whalebrew Installer for Windows
try {
$orgErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = "Stop"
$VERSION = "0.1.0"
$BINARY_URL = "https://github.com/3846masa/whalebrew/releases/download/$VERSION/whalebrew-Windows-x86_64.exe"
$USER_PATH = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User)
$WHALEBREW_INSTALL_PATH = [Environment]::GetEnvironmentVariable("WHALEBREW_INSTALL_PATH", [System.EnvironmentVariableTarget]::User)
if ($WHALEBREW_INSTALL_PATH -eq $null -or $WHALEBREW_INSTALL_PATH -eq '') {
$WHALEBREW_INSTALL_PATH = 'C:\whalebrew';
[Environment]::SetEnvironmentVariable("WHALEBREW_INSTALL_PATH", $WHALEBREW_INSTALL_PATH, [System.EnvironmentVariableTarget]::User)
}
if (![System.IO.Directory]::Exists($WHALEBREW_INSTALL_PATH)) {
[System.IO.Directory]::CreateDirectory($WHALEBREW_INSTALL_PATH)
}
if ($($USER_PATH).ToLower().Contains($($WHALEBREW_INSTALL_PATH).ToLower()) -eq $false) {
[Environment]::SetEnvironmentVariable("Path", "$USER_PATH;%WHALEBREW_INSTALL_PATH%", [System.EnvironmentVariableTarget]::User)
}
Write-Output "`nDownloading Whalebrew from : $BINARY_URL"
$WHALEBREW_PATH = Join-Path $WHALEBREW_INSTALL_PATH "whalebrew.exe"
(New-Object System.Net.WebClient).DownloadFile($BINARY_URL, "$WHALEBREW_PATH")
Write-Output "`nInstalled whalebrew to `"$WHALEBREW_PATH`"`n"
}
catch {
$Host.UI.WriteErrorLine("`nFailed to install whalebrew...`n")
Write-Error $error[1]
}
finally {
$ErrorActionPreference = $orgErrorActionPreference
}