From 8eb90f7ac1ccdcdd77b28df3d09a3dca063b0135 Mon Sep 17 00:00:00 2001 From: Brian Phillips <28457+brianphillips@users.noreply.github.com> Date: Tue, 30 Aug 2022 16:48:54 -0500 Subject: [PATCH 1/3] Fix loading of nvm for brew-installed nvm This reverts to the original (working) version from 2017. During the most recent refactor to use the `_bash_it_homebrew_check` helper method, it was overlooked that `${BASH_IT_HOMEBREW_PREFIX}/nvm.sh` is not the equivalent to `$(brew --prefix nvm)/nvm.sh` since `BASH_IT_HOMEBREW_PREFIX` is set from `brew --prefix` instead of `brew --prefix nvm`. --- plugins/available/nvm.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index 0e6da5d8..3966cdf2 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -10,9 +10,9 @@ about-plugin 'node version manager configuration' export NVM_DIR="${NVM_DIR:-$HOME/.nvm}" # This loads nvm -if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" ]] +if _bash_it_homebrew_check && [[ -s "$(brew --prefix nvm)/nvm.sh" ]] then - source "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" + source "$(brew --prefix nvm)/nvm.sh" else [[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" fi From 6661159b865249b6e15b2e0dc21a057f728f0b08 Mon Sep 17 00:00:00 2001 From: Brian Phillips <28457+brianphillips@users.noreply.github.com> Date: Fri, 9 Jun 2023 11:34:26 -0500 Subject: [PATCH 2/3] attempt to be more efficient when checking for brew-managed NVM install --- plugins/available/nvm.plugin.bash | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index 3966cdf2..7e123fc0 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -9,8 +9,16 @@ cite about-plugin about-plugin 'node version manager configuration' export NVM_DIR="${NVM_DIR:-$HOME/.nvm}" + +# first check if NVM is managed by brew +NVM_BREW_PREFIX="" +if _bash_it_homebrew_check +then + NVM_BREW_PREFIX=$(brew --prefix nvm 2>/dev/null) +fi + # This loads nvm -if _bash_it_homebrew_check && [[ -s "$(brew --prefix nvm)/nvm.sh" ]] +if [[ -n "$NVM_BREW_PREFIX" && -s "${NVM_BREW_PREFIX}/nvm.sh" ]] then source "$(brew --prefix nvm)/nvm.sh" else From c5fdefece65ef716801201dfe936fd54e5296527 Mon Sep 17 00:00:00 2001 From: Brian Phillips <28457+brianphillips@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:04:47 -0500 Subject: [PATCH 3/3] reuse variable instead of invoking brew again --- plugins/available/nvm.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index 7e123fc0..4dc4c6d6 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -20,7 +20,7 @@ fi # This loads nvm if [[ -n "$NVM_BREW_PREFIX" && -s "${NVM_BREW_PREFIX}/nvm.sh" ]] then - source "$(brew --prefix nvm)/nvm.sh" + source "${NVM_BREW_PREFIX}/nvm.sh" else [[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" fi