mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 14:21:50 +00:00
[fix] nvm : Check if Node version is already active before switching
This commit is contained in:
parent
ffec9fec72
commit
03576d614c
7
nvm-exec
7
nvm-exec
@ -8,6 +8,13 @@ unset NVM_CD_FLAGS
|
|||||||
\. "$DIR/nvm.sh" --no-use
|
\. "$DIR/nvm.sh" --no-use
|
||||||
|
|
||||||
if [ -n "$NODE_VERSION" ]; then
|
if [ -n "$NODE_VERSION" ]; then
|
||||||
|
CURRENT_VERSION=$(nvm current)
|
||||||
|
|
||||||
|
if [ "$CURRENT_VERSION" == "$NODE_VERSION" ]; then
|
||||||
|
echo "Node.js version $NODE_VERSION is already active."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
nvm use "$NODE_VERSION" > /dev/null || exit 127
|
nvm use "$NODE_VERSION" > /dev/null || exit 127
|
||||||
elif ! nvm use >/dev/null 2>&1; then
|
elif ! nvm use >/dev/null 2>&1; then
|
||||||
echo "No NODE_VERSION provided; no .nvmrc file found" >&2
|
echo "No NODE_VERSION provided; no .nvmrc file found" >&2
|
||||||
|
Loading…
Reference in New Issue
Block a user