mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-10 16:49:06 +00:00
[Fix] install.sh
: support ~/.zprofile
This commit is contained in:

committed by
Jordan Harband

parent
c6269e0ac2
commit
7c929f8742
@@ -5,6 +5,7 @@ setup () {
|
||||
NVM_ENV=testing \. ../../install.sh
|
||||
touch ".bashrc"
|
||||
touch ".bash_profile"
|
||||
touch ".zprofile"
|
||||
touch ".zshrc"
|
||||
touch ".profile"
|
||||
touch "test_profile"
|
||||
@@ -16,7 +17,7 @@ cleanup () {
|
||||
unset NVM_DETECT_PROFILE
|
||||
unset SHELL
|
||||
unset -f setup cleanup die
|
||||
rm -f ".bashrc" ".bash_profile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&1
|
||||
rm -f ".bashrc" ".bash_profile" ".zprofile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&1
|
||||
}
|
||||
|
||||
die () { echo "$@" '$NVM_DETECT_PROFILE:' "$NVM_DETECT_PROFILE"; cleanup; exit 1; }
|
||||
@@ -77,7 +78,7 @@ fi
|
||||
|
||||
#
|
||||
# When profile detection fails via both $PROFILE and $SHELL, profile detection should select based on the existence of
|
||||
# one of the following files is the following order: .profile, .bashrc, .bash_profile, .zshrc and
|
||||
# one of the following files is the following order: .profile, .bashrc, .bash_profile, .zprofile, .zshrc and
|
||||
# return an empty value if everything fails
|
||||
#
|
||||
|
||||
@@ -101,9 +102,16 @@ if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then
|
||||
die "nvm_detect_profile should have selected .bash_profile"
|
||||
fi
|
||||
|
||||
# Otherwise, it should favor .zshrc if file exists
|
||||
# Otherwise, it should favor .zprofile if file exists
|
||||
rm ".bash_profile"
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zprofile" ]; then
|
||||
die "nvm_detect_profile should have selected .zprofile"
|
||||
fi
|
||||
|
||||
# Otherwise, it should favor .zshrc if file exists
|
||||
rm ".zprofile"
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
||||
die "nvm_detect_profile should have selected .zshrc"
|
||||
fi
|
||||
|
@@ -9,5 +9,6 @@ type nvm_profile_is_bash_or_zsh > /dev/null 2>&1 || die 'nvm_profile_is_bash_or_
|
||||
nvm_profile_is_bash_or_zsh "/home/nvm/.bashrc" || die '/home/nvm/.bashrc is bash profile'
|
||||
nvm_profile_is_bash_or_zsh "/home/nvm/.bash_profile" || die '/home/nvm/.bash_profile is bash profile'
|
||||
nvm_profile_is_bash_or_zsh "/home/nvm/.zshrc" || die '/home/nvm/.zshrc is zsh profile'
|
||||
nvm_profile_is_bash_or_zsh "/home/nvm/.zprofile" || die '/home/nvm/.zprofile is zsh profile'
|
||||
if nvm_profile_is_bash_or_zsh "/home/nvm/.bash"; then die '/home/nvm/.bash is not bash nor zsh profile'; fi
|
||||
if nvm_profile_is_bash_or_zsh "/home/nvm/.zsh" ; then die '/home/nvm/.zsh is not bash nor zsh profile'; fi
|
||||
|
Reference in New Issue
Block a user