From c6b10cd3c04b310c9b0b219356f7355b2f8af854 Mon Sep 17 00:00:00 2001 From: Johannes Edmeier Date: Sun, 8 Nov 2020 12:42:06 +0100 Subject: [PATCH] Prioritize nvm via env-var over bre-prefix As the `brew --prefix nvm` takes up to 2.5s on my machine, we should favor finding the `nvm.sh` using the `$NVM_DIR` over using `brew --prefix` option. --- plugins/available/nvm.plugin.bash | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index e845d922..5740c22c 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -9,13 +9,17 @@ about-plugin 'node version manager configuration' export NVM_DIR=${NVM_DIR:-$HOME/.nvm} # This loads nvm -if command -v brew &>/dev/null && [ -s $(brew --prefix nvm)/nvm.sh ] +if [ -s "$NVM_DIR/nvm.sh" ] then - . $(brew --prefix nvm)/nvm.sh + source "$NVM_DIR/nvm.sh" else - [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" + if command -v brew &>/dev/null && [ -s $(brew --prefix nvm)/nvm.sh ] + then + source $(brew --prefix nvm)/nvm.sh + fi fi + if ! command -v nvm &>/dev/null then function nvm() {