Merge pull request #597 from danielb2/which

Fix `nvm which` to use conventional direct path to program, like system `which`
master
Jordan Harband 2014-12-19 13:05:39 -08:00
commit 0ac2c787be
2 changed files with 5 additions and 4 deletions

4
nvm.sh
View File

@ -965,7 +965,7 @@ nvm() {
if [ "_$VERSION" = '_system' ]; then if [ "_$VERSION" = '_system' ]; then
if nvm_has_system_node >/dev/null 2>&1; then if nvm_has_system_node >/dev/null 2>&1; then
echo $(nvm use system && echo dirname $(which node)) echo $(nvm use system > /dev/null 2>&1 && echo $(which node))
return return
else else
echo "System version of node not found." >&2 echo "System version of node not found." >&2
@ -982,7 +982,7 @@ nvm() {
echo "$VERSION version is not installed yet" >&2 echo "$VERSION version is not installed yet" >&2
return 1 return 1
fi fi
echo $NVM_DIR/$VERSION/bin echo $NVM_DIR/$VERSION/bin/node
;; ;;
"alias" ) "alias" )
mkdir -p "$NVM_DIR/alias" mkdir -p "$NVM_DIR/alias"

View File

@ -9,12 +9,13 @@ die () { echo $@ ; exit 1; }
# The result should contain only the appropriate version numbers. # The result should contain only the appropriate version numbers.
nvm which 0.0.2 | grep "$NVM_DIR/v0.0.2/bin" > /dev/null nvm which 0.0.2
nvm which 0.0.2 | grep "$NVM_DIR/v0.0.2/bin/node" > /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
die '"nvm which 0.0.2" did not contain the correct path' die '"nvm which 0.0.2" did not contain the correct path'
fi fi
nvm which 0.0.20 | grep "$NVM_DIR/v0.0.20/bin" > /dev/null nvm which 0.0.20 | grep "$NVM_DIR/v0.0.20/bin/node" > /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
die '"nvm which 0.0.2" did not contain the correct path' die '"nvm which 0.0.2" did not contain the correct path'
fi fi