-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
29 lines (21 loc) · 1010 Bytes
/
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
$ErrorActionPreference = 'Stop'
$repo = "hamflx/fetchbrowser"
$file = "fb.exe"
$releases = "https://api.github.com/repos/${repo}/releases"
Write-Host Determining latest release
$tag = (Invoke-WebRequest $releases | ConvertFrom-Json)[0].tag_name
$download = "https://github.com/${repo}/releases/download/${tag}/${file}"
$fb_dir = "${HOME}\.fb"
$fb_bin_dir = "${fb_dir}\bin"
$fb_bin_path = "${fb_bin_dir}\$file"
New-Item "${fb_bin_dir}" -ItemType Directory -Force | Out-Null
Write-Host Dowloading latest release
Invoke-WebRequest $download -Out $fb_bin_path
$old_path = [System.Environment]::GetEnvironmentVariable("PATH", "User")
if (!(";${old_path};".ToLower() -like "*;${fb_bin_dir};*".ToLower())) {
$new_path = $old_path + [IO.Path]::PathSeparator + $fb_bin_dir
[Environment]::SetEnvironmentVariable("PATH", $new_path, "User")
$Env:Path += ";${fb_bin_dir}"
}
Write-Host "Installation successfully. ``fb`` is now available in your PATH."
Write-Host "Example: ``fb 98`` to download Chromium 98."