33setup () {
44 HOME=" ."
55 NVM_ENV=testing \. ../../install.sh
6+ ZDOTDIR=" $HOME /zdotdir"
7+ mkdir -p zdotdir
68 touch " .bashrc"
79 touch " .bash_profile"
810 touch " .zprofile"
911 touch " .zshrc"
1012 touch " .profile"
1113 touch " test_profile"
14+ touch " zdotdir/.zshrc"
15+ touch " zdotdir/.zprofile"
1216}
1317
1418cleanup () {
@@ -17,7 +21,9 @@ cleanup () {
1721 unset NVM_DETECT_PROFILE
1822 unset SHELL
1923 unset -f setup cleanup die
24+ unset ZDOTDIR
2025 rm -f " .bashrc" " .bash_profile" " .zprofile" " .zshrc" " .profile" " test_profile" > " /dev/null" 2>&1
26+ rm -rf zdot>&1
2127}
2228
2329die () { echo " $@ " ' $NVM_DETECT_PROFILE:' " $NVM_DETECT_PROFILE " ; cleanup; exit 1; }
@@ -46,8 +52,14 @@ if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
4652 die " nvm_detect_profile ignored \$ PROFILE"
4753fi
4854
49- # .zshrc should be detected for zsh
55+ # zdotdir/ .zshrc should be detected for zsh
5056NVM_DETECT_PROFILE=" $( SHELL=" /bin/zsh" ; unset PROFILE; nvm_detect_profile) "
57+ if [ " $NVM_DETECT_PROFILE " != " $ZDOTDIR /.zshrc" ]; then
58+ die " nvm_detect_profile didn't pick \$ ZDOTDIR/.zshrc for zsh"
59+ fi
60+
61+ # .zshrc should be detected for zsh
62+ NVM_DETECT_PROFILE=" $( SHELL=" /bin/zsh" ; unset PROFILE; unset ZDOTDIR; nvm_detect_profile) "
5163if [ " $NVM_DETECT_PROFILE " != " $HOME /.zshrc" ]; then
5264 die " nvm_detect_profile didn't pick \$ HOME/.zshrc for zsh"
5365fi
@@ -58,7 +70,6 @@ if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
5870 die " nvm_detect_profile ignored \$ PROFILE"
5971fi
6072
61-
6273#
6374# Confirm $PROFILE is only returned when it points to a valid file
6475#
@@ -102,16 +113,30 @@ if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then
102113 die " nvm_detect_profile should have selected .bash_profile"
103114fi
104115
105- # Otherwise, it should favor .zprofile if file exists
116+ # Otherwise, it should favor zdotdir/ .zprofile if file exists
106117rm " .bash_profile"
107118NVM_DETECT_PROFILE=" $( unset SHELL; nvm_detect_profile) "
119+ if [ " $NVM_DETECT_PROFILE " != " $ZDOTDIR /.zprofile" ]; then
120+ die " nvm_detect_profile should have selected zdotdir/.zprofile"
121+ fi
122+
123+ # Otherwise, it should favor .zprofile if file exists
124+ rm " zdotdir/.zprofile"
125+ NVM_DETECT_PROFILE=" $( unset SHELL; unset ZDOTDIR; nvm_detect_profile) "
108126if [ " $NVM_DETECT_PROFILE " != " $HOME /.zprofile" ]; then
109127 die " nvm_detect_profile should have selected .zprofile"
110128fi
111129
112- # Otherwise, it should favor .zshrc if file exists
130+ # Otherwise, it should favor zdotdir/ .zshrc if file exists
113131rm " .zprofile"
114132NVM_DETECT_PROFILE=" $( unset SHELL; nvm_detect_profile) "
133+ if [ " $NVM_DETECT_PROFILE " != " $ZDOTDIR /.zshrc" ]; then
134+ die " nvm_detect_profile should have selected zdotdir/.zshrc"
135+ fi
136+
137+ # Otherwise, it should favor .zshrc if file exists
138+ rm " zdotdir/.zshrc"
139+ NVM_DETECT_PROFILE=" $( unset SHELL; unset ZDOTDIR; nvm_detect_profile) "
115140if [ " $NVM_DETECT_PROFILE " != " $HOME /.zshrc" ]; then
116141 die " nvm_detect_profile should have selected .zshrc"
117142fi
0 commit comments