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
Diff
1diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
2index 084b4846f47065082830f1630b4dff1221e98ec1..6a5afecfab18c5e6406d118784aa408a7e8a1aa8 100644
3--- a/plugins/nvm/nvm.plugin.zsh
4+++ b/plugins/nvm/nvm.plugin.zsh
5@@ -45,7 +45,6 @@ function _omz_setup_autoload {
6 # Autoload nvm when finding a .nvmrc file in the current directory
7 # Adapted from: https://github.com/nvm-sh/nvm#zsh
8 function load-nvmrc {
9- local node_version="$(nvm version)"
10 local nvmrc_path="$(nvm_find_nvmrc)"
11 local nvm_silent=""
12 zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent"
13@@ -58,10 +57,8 @@ function _omz_setup_autoload {
14 elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
15 nvm use $nvm_silent
16 fi
17- elif [[ "$node_version" != "$(nvm version default)" ]]; then
18- if [[ -z $nvm_silent ]]; then
19- echo "Reverting to nvm default version"
20- fi
21+ elif [[ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ]] && [[ "$(nvm version)" != "$(nvm version default)" ]]; then
22+ [[ -z $nvm_silent ]] && echo "Reverting to nvm default version"
2324 nvm use default $nvm_silent
25 fi