-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env pwsh | ||
# Copyright 2018 the Deno authors. All rights reserved. MIT license. | ||
# TODO(everyone): Keep this script simple and easily auditable. | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
||
if ($v) { | ||
$Version = "v${v}" | ||
} | ||
if ($args.Length -eq 1) { | ||
$Version = $args.Get(0) | ||
} | ||
|
||
$Install = $env:BP_INSTALL | ||
$BinDir = if ($Install) { | ||
"$Install\bin" | ||
} else { | ||
"$Home\.backpack-bin\bin" | ||
} | ||
|
||
$Zip = "$BinDir\backpack.zip" | ||
$Exe = "$BinDir\bp.exe" | ||
$Target = 'x86_64-windows' | ||
|
||
# GitHub requires TLS 1.2 | ||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | ||
|
||
$Uri = if (!$Version) { | ||
"https://github.com/rusty-ferris-club/backpack/releases/latest/download/backpack-${Target}.zip" | ||
} else { | ||
"https://github.com/rusty-ferris-club/backpack/releases/download/${Version}/backpack-${Target}.zip" | ||
} | ||
|
||
if (!(Test-Path $BinDir)) { | ||
New-Item $BinDir -ItemType Directory | Out-Null | ||
} | ||
|
||
curl.exe -Lo $Zip $Uri | ||
|
||
tar.exe xf $Zip -C $BinDir | ||
|
||
Remove-Item $Zip | ||
|
||
$User = [EnvironmentVariableTarget]::User | ||
$Path = [Environment]::GetEnvironmentVariable('Path', $User) | ||
if (!(";$Path;".ToLower() -like "*;$BinDir;*".ToLower())) { | ||
[Environment]::SetEnvironmentVariable('Path', "$Path;$BinDir", $User) | ||
$Env:Path += ";$BinDir" | ||
} | ||
|
||
Write-Output "Backpack was installed successfully to $Exe" | ||
Write-Output "Run 'bp --help' to get started" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/sh | ||
# Copyright 2019 the Deno authors. All rights reserved. MIT license. | ||
# TODO(everyone): Keep this script simple and easily auditable. | ||
|
||
set -e | ||
|
||
if ! command -v unzip >/dev/null; then | ||
echo "Error: unzip is required to install Backpack." 1>&2 | ||
exit 1 | ||
fi | ||
|
||
if [ "$OS" = "Windows_NT" ]; then | ||
target="x86_64-windows" | ||
else | ||
case $(uname -sm) in | ||
"Darwin x86_64") target="x86_64-apple-darwin" ;; | ||
"Darwin arm64") target="aarch64-apple-darwin" ;; | ||
*) target="x86_64-unknown-linux-gnu" ;; | ||
esac | ||
fi | ||
|
||
if [ $# -eq 0 ]; then | ||
uri="https://github.com/rusty-ferris-club/releases/latest/download/backpack-${target}.zip" | ||
else | ||
uri="https://github.com/rusty-ferris-club/releases/download/${1}/backpack-${target}.zip" | ||
fi | ||
|
||
install="${BP_INSTALL:-$HOME/.backpack-bin}" | ||
bin_dir="$install/bin" | ||
exe="$bin_dir/bp" | ||
|
||
if [ ! -d "$bin_dir" ]; then | ||
mkdir -p "$bin_dir" | ||
fi | ||
|
||
curl --fail --location --progress-bar --output "$exe.zip" "$uri" | ||
unzip -d "$bin_dir" -o "$exe.zip" | ||
chmod +x "$exe" | ||
rm "$exe.zip" | ||
|
||
echo "Backpack was installed successfully to $exe" | ||
if command -v bp >/dev/null; then | ||
echo "Run 'bp --help' to get started" | ||
else | ||
case $SHELL in | ||
/bin/zsh) shell_profile=".zshrc" ;; | ||
*) shell_profile=".bashrc" ;; | ||
esac | ||
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)" | ||
echo " export BP_INSTALL=\"$install\"" | ||
echo " export PATH=\"\$BP_INSTALL/bin:\$PATH\"" | ||
echo "Run '$exe --help' to get started" | ||
fi |