commit | 47d5982ef8bd6e2e5ca5c8e0b108910b5937a291 | [log] [tgz] |
---|---|---|
author | Tim Caswell <tim@creationix.com> | Mon Apr 19 10:22:28 2010 -0500 |
committer | Tim Caswell <tim@creationix.com> | Mon Apr 19 10:22:28 2010 -0500 |
tree | 01e775415130dd7a9eb302f9af337aa1a846ea1a | |
parent | 4d2e6045eb6c57f26aed1e4a3af149b74f39c02c [diff] |
Update to replace an old nvm path if it exists already in $PATH.
diff --git a/nvm.sh b/nvm.sh index 0f9c487..d3c9c34 100644 --- a/nvm.sh +++ b/nvm.sh
@@ -78,8 +78,12 @@ 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" )