mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-09 14:40:06 +00:00

committed by
Jordan Harband

parent
37e0977e60
commit
68fe26a5e4
@@ -14,6 +14,8 @@ cleanup () {
|
||||
unset HOME
|
||||
unset NVM_ENV
|
||||
unset NVM_DETECT_PROFILE
|
||||
unset BASH_VERSION
|
||||
unset ZSH_VERSION
|
||||
unset -f setup cleanup die
|
||||
rm -f ".bashrc" ".bash_profile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&1
|
||||
}
|
||||
@@ -27,7 +29,7 @@ setup
|
||||
#
|
||||
|
||||
# .bashrc should be detected for bash
|
||||
NVM_DETECT_PROFILE="$(SHELL="/bin/bash"; unset PROFILE; nvm_detect_profile)"
|
||||
NVM_DETECT_PROFILE="$(BASH_VERSION="1"; unset PROFILE; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then
|
||||
die "nvm_detect_profile didn't pick \$HOME/.bashrc for bash"
|
||||
fi
|
||||
@@ -39,7 +41,7 @@ if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
||||
fi
|
||||
|
||||
# .zshrc should be detected for zsh
|
||||
NVM_DETECT_PROFILE="$(SHELL="/usr/bin/zsh"; unset PROFILE; nvm_detect_profile)"
|
||||
NVM_DETECT_PROFILE="$(ZSH_VERSION="1"; unset PROFILE; unset BASH_VERSION; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
||||
die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh"
|
||||
fi
|
||||
@@ -56,7 +58,7 @@ fi
|
||||
#
|
||||
|
||||
# $PROFILE is a valid file
|
||||
NVM_DETECT_PROFILE="$(PROFILE="test_profile"; nvm_detect_profile)"
|
||||
NVM_DETECT_PROFILE="$(PROFILE="test_profile"; unset ZSH_VERSION; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
||||
die "nvm_detect_profile didn't pick \$PROFILE when it was a valid file"
|
||||
fi
|
||||
@@ -75,35 +77,35 @@ fi
|
||||
#
|
||||
|
||||
# It should favor .profile if file exists
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||
NVM_DETECT_PROFILE="$(unset BASH_VERSION; unset ZSH_VERSION; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.profile" ]; then
|
||||
die "nvm_detect_profile should have selected .profile"
|
||||
fi
|
||||
|
||||
# Otherwise, it should favor .bashrc if file exists
|
||||
rm ".profile"
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||
NVM_DETECT_PROFILE="$(unset BASH_VERSION; unset ZSH_VERSION; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then
|
||||
die "nvm_detect_profile should have selected .bashrc"
|
||||
fi
|
||||
|
||||
# Otherwise, it should favor .bash_profile if file exists
|
||||
rm ".bashrc"
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||
NVM_DETECT_PROFILE="$(unset BASH_VERSION; unset ZSH_VERSION; nvm_detect_profile)"
|
||||
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
|
||||
rm ".bash_profile"
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||
NVM_DETECT_PROFILE="$(unset BASH_VERSION; unset ZSH_VERSION; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
||||
die "nvm_detect_profile should have selected .zshrc"
|
||||
fi
|
||||
|
||||
# It should be empty if none is found
|
||||
rm ".zshrc"
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||
NVM_DETECT_PROFILE="$(unset BASH_VERSION; unset ZSH_VERSION; nvm_detect_profile)"
|
||||
if [ ! -z "$NVM_DETECT_PROFILE" ]; then
|
||||
die "nvm_detect_profile should have returned an empty value"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user