PROFILE env var should override detected profile
Add tests for PROFILE overriding detected files
parent
cb138a1815
commit
918fcb4bd2
|
@ -115,6 +115,10 @@ install_nvm_as_script() {
|
||||||
# Otherwise, an empty string is returned
|
# Otherwise, an empty string is returned
|
||||||
#
|
#
|
||||||
nvm_detect_profile() {
|
nvm_detect_profile() {
|
||||||
|
if [ -n "$PROFILE" -a -f "$PROFILE" ]; then
|
||||||
|
echo "$PROFILE"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
local DETECTED_PROFILE
|
local DETECTED_PROFILE
|
||||||
DETECTED_PROFILE=''
|
DETECTED_PROFILE=''
|
||||||
|
@ -132,9 +136,7 @@ nvm_detect_profile() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$DETECTED_PROFILE" ]; then
|
if [ -z "$DETECTED_PROFILE" ]; then
|
||||||
if [ -f "$PROFILE" ]; then
|
if [ -f "$HOME/.profile" ]; then
|
||||||
DETECTED_PROFILE="$PROFILE"
|
|
||||||
elif [ -f "$HOME/.profile" ]; then
|
|
||||||
DETECTED_PROFILE="$HOME/.profile"
|
DETECTED_PROFILE="$HOME/.profile"
|
||||||
elif [ -f "$HOME/.bashrc" ]; then
|
elif [ -f "$HOME/.bashrc" ]; then
|
||||||
DETECTED_PROFILE="$HOME/.bashrc"
|
DETECTED_PROFILE="$HOME/.bashrc"
|
||||||
|
|
|
@ -31,6 +31,15 @@ _PROFILE=$(nvm_detect_profile)
|
||||||
echo "_\$_PROFILE: _$_PROFILE" &&
|
echo "_\$_PROFILE: _$_PROFILE" &&
|
||||||
die "nvm_detect_profile didn't pick $SHELL and $HOME/.bashrc" )
|
die "nvm_detect_profile didn't pick $SHELL and $HOME/.bashrc" )
|
||||||
|
|
||||||
|
# But $PROFILE should override
|
||||||
|
PROFILE=test_profile
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" = "_$PROFILE" ] || ( echo "_\$_PROFILE: _$_PROFILE" &&
|
||||||
|
echo "_\$PROFILE: _$PROFILE" &&
|
||||||
|
die "nvm_detect_profile didn't pick \$PROFILE" )
|
||||||
|
unset PROFILE
|
||||||
|
|
||||||
|
|
||||||
#Let's force $SHELL to be zsh
|
#Let's force $SHELL to be zsh
|
||||||
SHELL="/usr/bin/zsh"
|
SHELL="/usr/bin/zsh"
|
||||||
|
|
||||||
|
@ -40,6 +49,14 @@ _PROFILE=$(nvm_detect_profile)
|
||||||
echo "_\$_PROFILE: _$_PROFILE" &&
|
echo "_\$_PROFILE: _$_PROFILE" &&
|
||||||
die "nvm_detect_profile didn't pick $SHELL and $HOME/.zshrc" )
|
die "nvm_detect_profile didn't pick $SHELL and $HOME/.zshrc" )
|
||||||
|
|
||||||
|
# But $PROFILE should override
|
||||||
|
PROFILE=test_profile
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" = "_$PROFILE" ] || ( echo "_\$_PROFILE: _$_PROFILE" &&
|
||||||
|
echo "_\$PROFILE: _$PROFILE" &&
|
||||||
|
die "nvm_detect_profile didn't pick \$PROFILE" )
|
||||||
|
unset PROFILE
|
||||||
|
|
||||||
# if we unset shell it looks for the files
|
# if we unset shell it looks for the files
|
||||||
unset SHELL
|
unset SHELL
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue