PROFILE env var should override detected profile

Add tests for PROFILE overriding detected files
This commit is contained in:
David Mankin
2015-09-15 23:34:02 +00:00
committed by Matthew Campbell
parent cb138a1815
commit 918fcb4bd2
2 changed files with 22 additions and 3 deletions

View File

@@ -115,6 +115,10 @@ install_nvm_as_script() {
# Otherwise, an empty string is returned
#
nvm_detect_profile() {
if [ -n "$PROFILE" -a -f "$PROFILE" ]; then
echo "$PROFILE"
return
fi
local DETECTED_PROFILE
DETECTED_PROFILE=''
@@ -132,9 +136,7 @@ nvm_detect_profile() {
fi
if [ -z "$DETECTED_PROFILE" ]; then
if [ -f "$PROFILE" ]; then
DETECTED_PROFILE="$PROFILE"
elif [ -f "$HOME/.profile" ]; then
if [ -f "$HOME/.profile" ]; then
DETECTED_PROFILE="$HOME/.profile"
elif [ -f "$HOME/.bashrc" ]; then
DETECTED_PROFILE="$HOME/.bashrc"