From 8911d1cbf282146faec4c883e358f4dad11613c2 Mon Sep 17 00:00:00 2001 From: Ian Grayson Date: Mon, 6 Dec 2021 09:55:17 -0800 Subject: [PATCH] fix: find-node.sh now respects .nvmrc --- scripts/find-node.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/find-node.sh b/scripts/find-node.sh index 2c7e894dd048d7..3c06f48aa02875 100755 --- a/scripts/find-node.sh +++ b/scripts/find-node.sh @@ -19,12 +19,16 @@ fi # Define NVM_DIR and source the nvm.sh setup script [ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm" +# Source nvm with '--no-use' and then `nvm use` to respect .nvmrc +# See: https://github.com/nvm-sh/nvm/issues/2053 if [[ -s "$HOME/.nvm/nvm.sh" ]]; then # shellcheck source=/dev/null - . "$HOME/.nvm/nvm.sh" + . "$HOME/.nvm/nvm.sh" --no-use + nvm use 2> /dev/null || nvm use default elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then # shellcheck source=/dev/null - . "$(brew --prefix nvm)/nvm.sh" + . "$(brew --prefix nvm)/nvm.sh" --no-use + nvm use 2> /dev/null || nvm use default fi # Set up the nodenv node version manager if present