Skip to content

Commit

Permalink
install.sh with πŸ’€ and πŸ”₯
Browse files Browse the repository at this point in the history
  • Loading branch information
denyzhirkov committed Mar 14, 2023
1 parent 2f2ebb9 commit 905926c
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env bash

error_msg() {
echo "Error:" "$@" >&2
echo " πŸ’€ $@" >&2
exit 1
}

info_msg() {
echo "$@ "
echo "[βœ“] $@ "
}

success_msg() {
echo "$@ "
echo " πŸ”₯ $@ "
}

if [[ ${OS:-} = Windows_NT ]]; then
Expand Down Expand Up @@ -62,56 +62,56 @@ fi
# Download and unzip
curl --fail --location --progress-bar --output "$exe.zip" "$var_uri" ||
error_msg "Failed to download bun from \"$var_uri\""
info_msg "[βœ“] Downloaded 'var' to $exe.zip"
info_msg "Downloaded 'var' to $exe.zip"

unzip -oqd "$bin_dir" "$exe.zip" ||
error_msg "Failed to extract 'var'"
info_msg "[βœ“] Extracted 'var' to $bin_dir/dist/$target"
info_msg "Extracted 'var' to $bin_dir/dist/$target"

mv "$bin_dir/dist/$target" "$exe" ||
error_msg "Failed to move extracted bun to destination"
info_msg "[βœ“] Moved 'var' to $exe"
info_msg "Moved 'var' to $exe"

rm -r "$bin_dir/dist" "$exe.zip" ||
error_msg "Failed to remove temporary files"
info_msg "[βœ“] Removed temporary files"
info_msg "Removed temporary files"

# Make the 'var' executable
chmod +x $exe
info_msg "[βœ“] Made 'var' executable"
info_msg "Made 'var' executable"

# bash
if [[ $SHELL == *bash ]]; then
if ! command -v var &>/dev/null; then
if [[ -f ~/.profile ]]; then
echo "# var" >> ~/.profile
echo "export PATH=\$PATH:$bin_dir" >> ~/.profile
echo "[βœ“] Updated ~/.profile"
info_msg "Updated ~/.profile"
fi
if [[ -f ~/.bashrc ]]; then
echo "# var" >> ~/.bashrc
echo "export PATH=\$PATH:$bin_dir" >> ~/.bashrc
echo "[βœ“] Updated ~/.bashrc"
info_msg "Updated ~/.bashrc"
fi
if [[ -f ~/.bash_profile ]]; then
echo "# var" >> ~/.bash_profile
echo "export PATH=\$PATH:$bin_dir" >> ~/.bash_profile
echo "[βœ“] Updated ~/.bash_profile"
info_msg "Updated ~/.bash_profile"
fi
if [[ -f ~/profile ]]; then
echo "# var" >> ~/profile
echo "export PATH=\$PATH:$bin_dir" >> ~/profile
echo "[βœ“] Updated ~/profile"
info_msg "Updated ~/profile"
fi
if [[ -f ~/bashrc ]]; then
echo "# var" >> ~/bashrc
echo "export PATH=\$PATH:$bin_dir" >> ~/bashrc
echo "[βœ“] Updated ~/bashrc"
info_msg "Updated ~/bashrc"
fi
if [[ -f ~/bash_profile ]]; then
echo "# var" >> ~/bash_profile
echo "export PATH=\$PATH:$bin_dir" >> ~/bash_profile
echo "[βœ“] Updated ~/bash_profile"
info_msg "Updated ~/bash_profile"
fi
success_msg "Successfully installed 'var' to $exe"
fi
Expand All @@ -123,42 +123,42 @@ if [[ $SHELL == *zsh ]]; then
if [[ -f ~/.zshrc ]]; then
echo "# var" >> ~/.zshrc
echo "export PATH=\$PATH:$bin_dir" >> ~/.zshrc
echo "[βœ“] Updated ~/.zshrc"
info_msg "Updated ~/.zshrc"
fi
if [[ -f ~/.zshenv ]]; then
echo "# var" >> ~/.zshenv
echo "export PATH=\$PATH:$bin_dir" >> ~/.zshenv
echo "[βœ“] Updated ~/.zshenv"
info_msg "Updated ~/.zshenv"
fi
if [[ -f ~/.zprofile ]]; then
echo "# var" >> ~/.zprofile
echo "export PATH=\$PATH:$bin_dir" >> ~/.zprofile
echo "[βœ“] Updated ~/.zprofile"
info_msg "Updated ~/.zprofile"
fi
if [[ -f ~/.zlogin ]]; then
echo "# var" >> ~/.zlogin
echo "export PATH=\$PATH:$bin_dir" >> ~/.zlogin
echo "[βœ“] Updated ~/.zlogin"
info_msg "Updated ~/.zlogin"
fi
if [[ -f ~/zshrc ]]; then
echo "# var" >> ~/zshrc
echo "export PATH=\$PATH:$bin_dir" >> ~/zshrc
echo "[βœ“] Updated ~/zshrc"
info_msg "Updated ~/zshrc"
fi
if [[ -f ~/zshenv ]]; then
echo "# var" >> ~/zshenv
echo "export PATH=\$PATH:$bin_dir" >> ~/zshenv
echo "[βœ“] Updated ~/zshenv"
info_msg "Updated ~/zshenv"
fi
if [[ -f ~/zprofile ]]; then
echo "# var" >> ~/zprofile
echo "export PATH=\$PATH:$bin_dir" >> ~/zprofile
echo "[βœ“] Updated ~/zprofile"
info_msg "Updated ~/zprofile"
fi
if [[ -f ~/zlogin ]]; then
echo "# var" >> ~/zlogin
echo "export PATH=\$PATH:$bin_dir" >> ~/zlogin
echo "[βœ“] Updated ~/zlogin"
info_msg "Updated ~/zlogin"
fi
success_msg "Successfully installed 'var' to $exe"
fi
Expand All @@ -168,9 +168,9 @@ fi
if [[ $SHELL == *fish ]]; then
if ! command -v var &>/dev/null; then
echo "set -gx PATH \$PATH $exe" >> ~/.config/fish/config.fish
success_msg "[βœ“] Successfully installed 'var' to $exe"
success_msg "Successfully installed 'var' to $exe"
fi
fi

success_msg "\nRun 'var' or 'var -h' to get started\n"
success_msg "Restart terminal and run 'var' or 'var -h' to get started"
exit 0

0 comments on commit 905926c

Please sign in to comment.