Skip to content

Commit

Permalink
perf(nvm): don't call nvm version on every cd
Browse files Browse the repository at this point in the history
Now we only call `nvm version` in case we changed directory and we are
not anymore in a `.nvmrc` directory.
See nvm-sh/nvm#2874
  • Loading branch information
carlosala committed Mar 4, 2024
1 parent 94aa49c commit fd01fd6
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions plugins/nvm/nvm.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit fd01fd6

Please sign in to comment.