-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
64 lines (54 loc) · 1.5 KB
/
install.sh
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -e
if ! command -v unzip >/dev/null; then
echo "Error: unzip is required to install bvm." 1>&2
exit 1
fi
if [ "$OS" = "Windows_NT" ]; then
echo "Error: bun requires Windows Subsystem for Linux." 1>&2
exit 1
else
case $(uname -sm) in
"Darwin x86_64") target="darwin_x86_64" ;;
"Darwin arm64") target="darwin_arm64" ;;
"Linux x86_64") target="linux_x86_64" ;;
*) echo "Unsupported OS + CPU combination: $(uname -sm)"; exit 1 ;;
esac
fi
bvm_url="https://github.com/chathula/bvm/releases/latest/download/bvm_${target}.zip"
bvm_dir="${BVM_DIR:-$HOME/.bvm}"
bvm_bin_dir="$bvm_dir/bin"
exe="$bvm_bin_dir/bvm"
if [ ! -d "$bvm_bin_dir" ]; then
mkdir -p "$bvm_bin_dir"
fi
if [ "$1" = "" ]; then
cd "$bvm_bin_dir"
curl --fail --location --progress-bar -k --output "$exe.zip" "$bvm_url"
unzip -o "$exe.zip"
rm "$exe.zip"
else
echo "Install path override detected: $1"
if [ ! -f "$1" ]; then
echo "File does not exist: $1"
exit 1
fi
cp "$1" "$exe"
fi
cd "$bvm_bin_dir"
chmod +x "$exe"
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".basrc" ;;
esac
if [ ! $BVM_DIR ];then
echo -e '\n# bvm & bun'
command echo "export BVM_DIR=\"$bvm_dir\"" >> "$HOME/$shell_profile"
command echo "export PATH=\"\$BVM_DIR/bin:\$PATH\"" >> "$HOME/$shell_profile"
fi
echo "bvm was installed successfully to $exe"
if command -v bvm >/dev/null; then
echo "Run 'bvm --help' to get started."
else
echo "Reopen your shell, or run 'source $HOME/$shell_profile' to get started"
fi