Skip to content

Commit

Permalink
Update to replace an old nvm path if it exists already in $PATH.
Browse files Browse the repository at this point in the history
  • Loading branch information
creationix committed Apr 19, 2010
1 parent 4d2e604 commit 47d5982
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nvm.sh
Expand Up @@ -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" )
Expand Down

0 comments on commit 47d5982

Please sign in to comment.