Update to replace an old nvm path if it exists already in $PATH.

master
Tim Caswell 2010-04-19 10:22:28 -05:00
parent 4d2e6045eb
commit 47d5982ef8
1 changed files with 6 additions and 2 deletions

8
nvm.sh
View File

@ -78,8 +78,12 @@ nvm()
nvm help
return;
fi
# TODO: Remove old nvm paths before adding this one
PATH="$NVM_DIR/$2/bin:$PATH"
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$2/bin${PATH#*$NVM_DIR/*/bin}
else
PATH="$NVM_DIR/$2/bin:$PATH"
fi
export PATH
echo "Now using node $2"
;;
"list" )