3
3
setup () {
4
4
HOME=" ."
5
5
NVM_ENV=testing \. ../../install.sh
6
+ ZDOTDIR=" $HOME /zdotdir"
7
+ mkdir -p zdotdir
6
8
touch " .bashrc"
7
9
touch " .bash_profile"
8
10
touch " .zprofile"
9
11
touch " .zshrc"
10
12
touch " .profile"
11
13
touch " test_profile"
14
+ touch " zdotdir/.zshrc"
15
+ touch " zdotdir/.zprofile"
12
16
}
13
17
14
18
cleanup () {
@@ -17,7 +21,9 @@ cleanup () {
17
21
unset NVM_DETECT_PROFILE
18
22
unset SHELL
19
23
unset -f setup cleanup die
24
+ unset ZDOTDIR
20
25
rm -f " .bashrc" " .bash_profile" " .zprofile" " .zshrc" " .profile" " test_profile" > " /dev/null" 2>&1
26
+ rm -rf zdot>&1
21
27
}
22
28
23
29
die () { echo " $@ " ' $NVM_DETECT_PROFILE:' " $NVM_DETECT_PROFILE " ; cleanup; exit 1; }
@@ -46,8 +52,14 @@ if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
46
52
die " nvm_detect_profile ignored \$ PROFILE"
47
53
fi
48
54
49
- # .zshrc should be detected for zsh
55
+ # zdotdir/ .zshrc should be detected for zsh
50
56
NVM_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) "
51
63
if [ " $NVM_DETECT_PROFILE " != " $HOME /.zshrc" ]; then
52
64
die " nvm_detect_profile didn't pick \$ HOME/.zshrc for zsh"
53
65
fi
@@ -58,7 +70,6 @@ if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
58
70
die " nvm_detect_profile ignored \$ PROFILE"
59
71
fi
60
72
61
-
62
73
#
63
74
# Confirm $PROFILE is only returned when it points to a valid file
64
75
#
@@ -102,16 +113,30 @@ if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then
102
113
die " nvm_detect_profile should have selected .bash_profile"
103
114
fi
104
115
105
- # Otherwise, it should favor .zprofile if file exists
116
+ # Otherwise, it should favor zdotdir/ .zprofile if file exists
106
117
rm " .bash_profile"
107
118
NVM_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) "
108
126
if [ " $NVM_DETECT_PROFILE " != " $HOME /.zprofile" ]; then
109
127
die " nvm_detect_profile should have selected .zprofile"
110
128
fi
111
129
112
- # Otherwise, it should favor .zshrc if file exists
130
+ # Otherwise, it should favor zdotdir/ .zshrc if file exists
113
131
rm " .zprofile"
114
132
NVM_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) "
115
140
if [ " $NVM_DETECT_PROFILE " != " $HOME /.zshrc" ]; then
116
141
die " nvm_detect_profile should have selected .zshrc"
117
142
fi
0 commit comments