From 52d743363ca343fa1a8bb265a8284f9c9100e88a Mon Sep 17 00:00:00 2001 From: Eric Henderson Date: Tue, 21 Apr 2020 11:34:01 -0400 Subject: [PATCH] Add support for NVM_AUTO_USE_IGNORE_VERSION and NVM_AUTO_USE_IGNORE_PATH as methods for skiping the auto-use in specific cases --- zsh-nvm.plugin.zsh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zsh-nvm.plugin.zsh b/zsh-nvm.plugin.zsh index d85e94c..59e4bbb 100644 --- a/zsh-nvm.plugin.zsh +++ b/zsh-nvm.plugin.zsh @@ -169,9 +169,15 @@ _zsh_nvm_auto_use() { local nvmrc_path="$(nvm_find_nvmrc)" if [[ -n "$nvmrc_path" ]]; then + local nvmrc_dir="$(dirname "$nvmrc_path")" + local nvmrc_version="$(cat "$nvmrc_path")" local nvmrc_node_version="$(nvm version $(cat "$nvmrc_path"))" - if [[ "$nvmrc_node_version" = "N/A" ]]; then + if [[ -v NVM_AUTO_USE_IGNORE_VERSION ]] && [[ ${NVM_AUTO_USE_IGNORE_VERSION[(Ie)$nvmrc_version]} -gt 0 ]]; then + echo "Detected nvm version <$nvmrc_version>, but this version is set to be ignored" + elif [[ -v NVM_AUTO_USE_IGNORE_PATH ]] && [[ ${NVM_AUTO_USE_IGNORE_PATH[(Ie)$nvmrc_dir]} -gt 0 ]]; then + echo "Detected nvm version <$nvmrc_version>, but this path is set to be ignored" + elif [[ "$nvmrc_node_version" = "N/A" ]]; then nvm install && export NVM_AUTO_USE_ACTIVE=true elif [[ "$nvmrc_node_version" != "$node_version" ]]; then nvm use && export NVM_AUTO_USE_ACTIVE=true