`nvm use system` should work as expected.

master
Jordan Harband 2014-07-14 11:49:49 -07:00
parent 9912f7cc46
commit e7ada80d08
2 changed files with 24 additions and 1 deletions

10
nvm.sh
View File

@ -549,9 +549,19 @@ nvm() {
if [ -n "$NVM_RC_VERSION" ]; then
VERSION=`nvm_version $NVM_RC_VERSION`
fi
else
if [ $2 = 'system' ]; then
if nvm_has_system_node && nvm deactivate; then
echo "Now using system version of node: $(node -v 2>/dev/null)."
return
else
echo "System version of node not found." >&2
return 127
fi
else
VERSION=`nvm_version $2`
fi
fi
if [ -z "$VERSION" ]; then
nvm help
return 127

View File

@ -0,0 +1,13 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../nvm.sh
nvm_has_system_node() { return 0; }
[ "$(nvm use system 2>&1 | tail -n1)" = "Now using system version of node: $(node -v)." ] || die "Could not use system version of node"
nvm_has_system_node() { return 1; }
[ "$(nvm use system 2>&1 | tail -n1)" = "System version of node not found." ] || die "Did not report error, system node not found"
nvm use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"