`nvm use system` should work as expected.
parent
9912f7cc46
commit
e7ada80d08
12
nvm.sh
12
nvm.sh
|
@ -550,7 +550,17 @@ nvm() {
|
||||||
VERSION=`nvm_version $NVM_RC_VERSION`
|
VERSION=`nvm_version $NVM_RC_VERSION`
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
VERSION=`nvm_version $2`
|
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
|
fi
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
nvm help
|
nvm help
|
||||||
|
|
|
@ -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"
|
||||||
|
|
Loading…
Reference in New Issue