From 03576d614c1725d07e72ac23ebb59009c9ea2b06 Mon Sep 17 00:00:00 2001 From: adssib <75389300+adssib@users.noreply.github.com> Date: Tue, 11 Mar 2025 23:06:48 -0400 Subject: [PATCH] [fix] nvm : Check if Node version is already active before switching --- nvm-exec | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nvm-exec b/nvm-exec index 44d5ddb..5b9411e 100755 --- a/nvm-exec +++ b/nvm-exec @@ -8,6 +8,13 @@ unset NVM_CD_FLAGS \. "$DIR/nvm.sh" --no-use 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 elif ! nvm use >/dev/null 2>&1; then echo "No NODE_VERSION provided; no .nvmrc file found" >&2