Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/more robust installer #787

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions cyfrinup/install
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -eo pipefail

# -----------------------------------------------------------
# Forked from Foundry.
Expand Down Expand Up @@ -32,7 +32,8 @@ banner

echo Installing cyfrinup...

CYFRIN_DIR="$HOME/.cyfrin"
BASE_DIR="${XDG_CONFIG_HOME:-$HOME}"
CYFRIN_DIR="${CYFRIN_DIR:-"$BASE_DIR/.cyfrin"}"
CYFRIN_BIN_DIR="$CYFRIN_DIR/bin"

CYFRINUP_URL="https://raw.githubusercontent.com/Cyfrin/aderyn/master/cyfrinup/cyfrinup"
Expand All @@ -46,7 +47,7 @@ chmod +x $BIN_PATH
# Store the correct profile file (i.e. .profile for bash or .zshrc for ZSH).
case $SHELL in
*/zsh)
PROFILE=$HOME/.zshrc
PROFILE="${ZDOTDIR-"$HOME"}/.zshenv"
PREF_SHELL=zsh
;;
*/bash)
Expand All @@ -57,6 +58,10 @@ case $SHELL in
PROFILE=$HOME/.config/fish/config.fish
PREF_SHELL=fish
;;
*/ash)
PROFILE=$HOME/.profile
PREF_SHELL=ash
;;
*)
echo "cyfrinup: could not detect shell, manually add ${CYFRIN_BIN_DIR} to your PATH."
exit 1
Expand All @@ -65,8 +70,15 @@ esac
# Only add cyfrinup if it isn't already in PATH.
if [[ ":$PATH:" != *":${CYFRIN_BIN_DIR}:"* ]]; then
# Add the cyfrinup directory to the path and ensure the old PATH variables remain.
echo >> $PROFILE && echo "export PATH=\"\$PATH:$CYFRIN_BIN_DIR\"" >> $PROFILE
if [[ "$PREF_SHELL" == "fish" ]]; then
echo >> "$PROFILE" && echo "fish_add_path -a $CYFRIN_BIN_DIR" >> "$PROFILE"
else
echo >> "$PROFILE" && echo "export PATH=\"\$PATH:$CYFRIN_BIN_DIR\"" >> "$PROFILE"
fi
fi

# Export the PATH directly in the current session
export PATH="$PATH:$CYFRIN_BIN_DIR"

echo && echo "Detected your preferred shell is ${PREF_SHELL} and added cyfrinup to PATH. Run 'source ${PROFILE}' or start a new terminal session to use cyfrin."
echo "Then, simply run 'cyfrinup' to install Cyfrin tool suite"
Loading