From d45d87b08feb3a0361e0564678e6d7e3a18e3751 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Wed, 12 Dec 2018 22:17:16 -0600 Subject: [PATCH] node: Make nvm lookup mechanism more efficient in homebrewed environment In homebrewed environment, avoid using `brew --prefix nvm` which is ruby based and is super slow. Instead, rely on homebrew standard behavior wherein all installed packages are available in canonical path $(brew --prefix)/opt/ (for nvm it would obviously be `$(brew --prefix)/opt/nvm`). NB: `$(brew --prefix)` (without additional argument) is a simple shell shortcut and doesn't have the same performance impact. --- modules/node/init.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/node/init.zsh b/modules/node/init.zsh index 75a7ebb..f452ec5 100644 --- a/modules/node/init.zsh +++ b/modules/node/init.zsh @@ -11,8 +11,10 @@ if [[ -s "$HOME/.nvm/nvm.sh" ]]; then source "$HOME/.nvm/nvm.sh" # Load package manager installed NVM into the shell session. -elif (( $+commands[brew] )) && [[ -d "$(brew --prefix nvm 2> /dev/null)" ]]; then +elif (( $+commands[brew] )) && \ + [[ -d "${nvm_prefix::="$(brew --prefix 2> /dev/null)"/opt/nvm}" ]]; then source "$(brew --prefix nvm)/nvm.sh" + unset nvm_prefix # Load manually installed nodenv into the shell session. elif [[ -s "$HOME/.nodenv/bin/nodenv" ]]; then