Skip to content

Commit

Permalink
Refactor install.sh to add phpvm_detect_profile function
Browse files Browse the repository at this point in the history
  • Loading branch information
Thavarshan committed Oct 6, 2024
1 parent a4be795 commit 31530db
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,34 @@
}
}

phpvm_detect_profile() {
if [ "${PROFILE-}" = '/dev/null' ]; then
return
fi

if [ -n "${PROFILE}" ] && [ -f "${PROFILE}" ]; then
phpvm_echo "${PROFILE}"
return
fi

local SHELL_TYPE
SHELL_TYPE="$(basename "$SHELL")"

if [ "$SHELL_TYPE" = "bash" ]; then
if [ -f "$HOME/.bashrc" ]; then
phpvm_echo "$HOME/.bashrc"
elif [ -f "$HOME/.bash_profile" ]; then
phpvm_echo "$HOME/.bash_profile"
fi
elif [ "$SHELL_TYPE" = "zsh" ]; then
if [ -f "$HOME/.zshrc" ]; then
phpvm_echo "$HOME/.zshrc"
elif [ -f "$HOME/.zprofile" ]; then
phpvm_echo "$HOME/.zprofile"
fi
fi
}

inject_phpvm_config() {
local PHPVM_PROFILE
PHPVM_PROFILE="$(phpvm_detect_profile)"
Expand Down

0 comments on commit 31530db

Please sign in to comment.