mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 14:21:50 +00:00
parent
d648a3b1ba
commit
cd22c84026
@ -296,10 +296,10 @@ nvm_detect_profile() {
|
|||||||
DETECTED_PROFILE="$HOME/.bash_profile"
|
DETECTED_PROFILE="$HOME/.bash_profile"
|
||||||
fi
|
fi
|
||||||
elif [ "${SHELL#*zsh}" != "$SHELL" ]; then
|
elif [ "${SHELL#*zsh}" != "$SHELL" ]; then
|
||||||
if [ -f "$HOME/.zshrc" ]; then
|
if [ -f "${ZDOTDIR:-${HOME}}/.zshrc" ]; then
|
||||||
DETECTED_PROFILE="$HOME/.zshrc"
|
DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zshrc"
|
||||||
elif [ -f "$HOME/.zprofile" ]; then
|
elif [ -f "${ZDOTDIR:-${HOME}}/.zprofile" ]; then
|
||||||
DETECTED_PROFILE="$HOME/.zprofile"
|
DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zprofile"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -3,12 +3,16 @@
|
|||||||
setup () {
|
setup () {
|
||||||
HOME="."
|
HOME="."
|
||||||
NVM_ENV=testing \. ../../install.sh
|
NVM_ENV=testing \. ../../install.sh
|
||||||
|
ZDOTDIR="$HOME/zdotdir"
|
||||||
|
mkdir -p zdotdir
|
||||||
touch ".bashrc"
|
touch ".bashrc"
|
||||||
touch ".bash_profile"
|
touch ".bash_profile"
|
||||||
touch ".zprofile"
|
touch ".zprofile"
|
||||||
touch ".zshrc"
|
touch ".zshrc"
|
||||||
touch ".profile"
|
touch ".profile"
|
||||||
touch "test_profile"
|
touch "test_profile"
|
||||||
|
touch "zdotdir/.zshrc"
|
||||||
|
touch "zdotdir/.zprofile"
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup () {
|
cleanup () {
|
||||||
@ -17,7 +21,9 @@ cleanup () {
|
|||||||
unset NVM_DETECT_PROFILE
|
unset NVM_DETECT_PROFILE
|
||||||
unset SHELL
|
unset SHELL
|
||||||
unset -f setup cleanup die
|
unset -f setup cleanup die
|
||||||
|
unset ZDOTDIR
|
||||||
rm -f ".bashrc" ".bash_profile" ".zprofile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&1
|
rm -f ".bashrc" ".bash_profile" ".zprofile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&1
|
||||||
|
rm -rf zdot>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
die () { echo "$@" '$NVM_DETECT_PROFILE:' "$NVM_DETECT_PROFILE"; cleanup; exit 1; }
|
die () { echo "$@" '$NVM_DETECT_PROFILE:' "$NVM_DETECT_PROFILE"; cleanup; exit 1; }
|
||||||
@ -46,8 +52,14 @@ if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
|||||||
die "nvm_detect_profile ignored \$PROFILE"
|
die "nvm_detect_profile ignored \$PROFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .zshrc should be detected for zsh
|
# zdotdir/.zshrc should be detected for zsh
|
||||||
NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; nvm_detect_profile)"
|
||||||
|
if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then
|
||||||
|
die "nvm_detect_profile didn't pick \$ZDOTDIR/.zshrc for zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# .zshrc should be detected for zsh
|
||||||
|
NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; unset ZDOTDIR; nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
||||||
die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh"
|
die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh"
|
||||||
fi
|
fi
|
||||||
@ -58,7 +70,6 @@ if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
|||||||
die "nvm_detect_profile ignored \$PROFILE"
|
die "nvm_detect_profile ignored \$PROFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Confirm $PROFILE is only returned when it points to a valid file
|
# Confirm $PROFILE is only returned when it points to a valid file
|
||||||
#
|
#
|
||||||
@ -102,16 +113,30 @@ if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then
|
|||||||
die "nvm_detect_profile should have selected .bash_profile"
|
die "nvm_detect_profile should have selected .bash_profile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Otherwise, it should favor .zprofile if file exists
|
# Otherwise, it should favor zdotdir/.zprofile if file exists
|
||||||
rm ".bash_profile"
|
rm ".bash_profile"
|
||||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||||
|
if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zprofile" ]; then
|
||||||
|
die "nvm_detect_profile should have selected zdotdir/.zprofile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Otherwise, it should favor .zprofile if file exists
|
||||||
|
rm "zdotdir/.zprofile"
|
||||||
|
NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zprofile" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zprofile" ]; then
|
||||||
die "nvm_detect_profile should have selected .zprofile"
|
die "nvm_detect_profile should have selected .zprofile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Otherwise, it should favor .zshrc if file exists
|
# Otherwise, it should favor zdotdir/.zshrc if file exists
|
||||||
rm ".zprofile"
|
rm ".zprofile"
|
||||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||||
|
if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then
|
||||||
|
die "nvm_detect_profile should have selected zdotdir/.zshrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Otherwise, it should favor .zshrc if file exists
|
||||||
|
rm "zdotdir/.zshrc"
|
||||||
|
NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
||||||
die "nvm_detect_profile should have selected .zshrc"
|
die "nvm_detect_profile should have selected .zshrc"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user