Skip to content
Myr

[Refactor] Improve profile detection in install script

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Peter Dave Hello · committed by Jordan Harband · parent d4e3f09 · Browse files · 1 file+17 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+17 added−13 removed

  • other:+17 added−13 removed

1 file+17 added−13 removed

modified:install.sh+17 added-13 removed
181 unmodified lines
182 return 3183 }184}185186nvm_try_profile() {187 if [ -z "${1-}" ] || [ ! -f "${1}" ]; then188 return 1189 fi190 echo "${1}"191}192193#194# Detect profile file if not specified as environment variable195# (eg: PROFILE=~/.myprofile)196# The echo'ed path is guaranteed to be an existing file
20 unmodified lines
217 DETECTED_PROFILE="$HOME/.zshrc"218 fi219220 if [ -z "$DETECTED_PROFILE" ]; then214 if [ -f "$HOME/.profile" ]; then215 DETECTED_PROFILE="$HOME/.profile"216 elif [ -f "$HOME/.bashrc" ]; then217 DETECTED_PROFILE="$HOME/.bashrc"218 elif [ -f "$HOME/.bash_profile" ]; then219 DETECTED_PROFILE="$HOME/.bash_profile"220 elif [ -f "$HOME/.zshrc" ]; then221 DETECTED_PROFILE="$HOME/.zshrc"222 fi221 for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zshrc"222 do223 if DETECTED_PROFILE="$(nvm_try_profile "${HOME}/${EACH_PROFILE}")"; then224 break225 fi226 done227 fi228229 if [ ! -z "$DETECTED_PROFILE" ]; then230 echo "$DETECTED_PROFILE"
134 unmodified lines
365# Unsets the various functions defined366# during the execution of the install script367#368nvm_reset() {365 unset -f nvm_reset nvm_has nvm_latest_version \366 nvm_source nvm_download install_nvm_as_script install_nvm_from_git \367 nvm_detect_profile nvm_check_global_modules nvm_do_install \368 nvm_install_dir nvm_node_version nvm_install_node369 unset -f nvm_has nvm_install_dir nvm_latest_version nvm_profile_is_bash_or_zsh \370 nvm_source nvm_node_version nvm_download install_nvm_from_git nvm_install_node \371 install_nvm_as_script nvm_try_profile nvm_detect_profile nvm_check_global_modules \372 nvm_do_install nvm_reset373}374375[ "_$NVM_ENV" = "_testing" ] || nvm_do_install376
1 unmodified line