mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-11-26 17:13:12 +07:00
Improve tools setup
Log full semver of tools installed with composer Refactor adding paths to PATH
This commit is contained in:
@ -60,6 +60,34 @@ get() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to get shell profile.
|
||||
get_shell_profile() {
|
||||
case "$SHELL" in
|
||||
*bash*)
|
||||
echo "${HOME}/.bashrc"
|
||||
;;
|
||||
*zsh*)
|
||||
echo "${HOME}/.zshrc"
|
||||
;;
|
||||
*)
|
||||
echo "${HOME}/.profile"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to add a path to the PATH variable.
|
||||
add_path() {
|
||||
path_to_add=$1
|
||||
[ ! -d "$path_to_add" ] && [[ ":$PATH:" == *":$path_to_add:"* ]] && return
|
||||
if [[ -n "$GITHUB_PATH" ]]; then
|
||||
echo "$path_to_add" | tee -a "$GITHUB_PATH" >/dev/null 2>&1
|
||||
else
|
||||
profile=$(get_shell_profile)
|
||||
([ -e "$profile" ] && grep -q ":$path_to_add\"" "$profile" 2>/dev/null) || echo "export PATH=\"\${PATH:+\${PATH}:}\"$path_to_add" | sudo tee -a "$profile" >/dev/null 2>&1
|
||||
fi
|
||||
export PATH="${PATH:+${PATH}:}$path_to_add"
|
||||
}
|
||||
|
||||
# Function to download and run scripts from GitHub releases with jsdeliver fallback.
|
||||
run_script() {
|
||||
repo=$1
|
||||
|
||||
Reference in New Issue
Block a user