File tree Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,19 @@ nvm_latest_version() {
14
14
echo " v0.33.1"
15
15
}
16
16
17
+ nvm_profile_is_bash_or_zsh () {
18
+ local TEST_PROFILE
19
+ TEST_PROFILE=" ${1-} "
20
+ case " ${TEST_PROFILE-} " in
21
+ * " /.bashrc" | * " /.bash_profile" | * " /.zshrc" )
22
+ return
23
+ ;;
24
+ * )
25
+ return 1
26
+ ;;
27
+ esac
28
+ }
29
+
17
30
#
18
31
# Outputs the location to NVM depending on:
19
32
# * The availability of $NVM_SOURCE
@@ -305,11 +318,9 @@ nvm_do_install() {
305
318
echo " => Append the following lines to the correct file yourself:"
306
319
command printf " ${SOURCE_STR} "
307
320
else
308
- case " ${NVM_PROFILE-} " in
309
- " .bashrc" | " .bash_profile" | " .zshrc" )
310
- BASH_OR_ZSH=true
311
- ;;
312
- esac
321
+ if nvm_profile_is_bash_or_zsh " ${NVM_PROFILE-} " ; then
322
+ BASH_OR_ZSH=true
323
+ fi
313
324
if ! command grep -qc ' /nvm.sh' " $NVM_PROFILE " ; then
314
325
echo " => Appending nvm source string to $NVM_PROFILE "
315
326
command printf " ${SOURCE_STR} " >> " $NVM_PROFILE "
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ die () { echo " $@ " ; exit 1; }
4
+
5
+ NVM_ENV=testing \. ../../install.sh
6
+
7
+ # nvm_profile_is_bash_or_zsh is available
8
+ type nvm_profile_is_bash_or_zsh > /dev/null 2>&1 || die ' nvm_profile_is_bash_or_zsh is not available'
9
+ nvm_profile_is_bash_or_zsh " /home/nvm/.bashrc" || die ' /home/nvm/.bashrc is bash profile'
10
+ nvm_profile_is_bash_or_zsh " /home/nvm/.bash_profile" || die ' /home/nvm/.bash_profile is bash profile'
11
+ nvm_profile_is_bash_or_zsh " /home/nvm/.zshrc" || die ' /home/nvm/.zshrc is zsh profile'
12
+ if nvm_profile_is_bash_or_zsh " /home/nvm/.bash" ; then die ' /home/nvm/.bash is not bash nor zsh profile' ; fi
13
+ if nvm_profile_is_bash_or_zsh " /home/nvm/.zsh" ; then die ' /home/nvm/.zsh is not bash nor zsh profile' ; fi
You can’t perform that action at this time.
0 commit comments