diff options
| author | Carlo Sala <carlosalag@protonmail.com> | 2024-03-04 11:08:49 +0100 |
|---|---|---|
| committer | Carlo Sala <carlosalag@protonmail.com> | 2024-03-04 11:11:35 +0100 |
| commit | fd01fd66ce27c669e5ffaea94460a37423d1e134 (patch) | |
| tree | dbee2805df19117dc8c9f47b5ff657b43ad04d68 /plugins/nvm | |
| parent | 94aa49c0b96fed98d2751107301c16f32de13383 (diff) | |
| download | zsh-fd01fd66ce27c669e5ffaea94460a37423d1e134.tar.gz zsh-fd01fd66ce27c669e5ffaea94460a37423d1e134.tar.bz2 zsh-fd01fd66ce27c669e5ffaea94460a37423d1e134.zip | |
perf(nvm): don't call `nvm version` on every cd
Now we only call `nvm version` in case we changed directory and we are
not anymore in a `.nvmrc` directory.
See https://github.com/nvm-sh/nvm/pull/2874
Diffstat (limited to 'plugins/nvm')
| -rw-r--r-- | plugins/nvm/nvm.plugin.zsh | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 084b4846f..6a5afecfa 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -45,7 +45,6 @@ function _omz_setup_autoload { # Autoload nvm when finding a .nvmrc file in the current directory # Adapted from: https://github.com/nvm-sh/nvm#zsh function load-nvmrc { - local node_version="$(nvm version)" local nvmrc_path="$(nvm_find_nvmrc)" local nvm_silent="" zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent" @@ -58,10 +57,8 @@ function _omz_setup_autoload { elif [[ "$nvmrc_node_version" != "$node_version" ]]; then nvm use $nvm_silent fi - elif [[ "$node_version" != "$(nvm version default)" ]]; then - if [[ -z $nvm_silent ]]; then - echo "Reverting to nvm default version" - fi + elif [[ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ]] && [[ "$(nvm version)" != "$(nvm version default)" ]]; then + [[ -z $nvm_silent ]] && echo "Reverting to nvm default version" nvm use default $nvm_silent fi |
