[readme] optimize calling of `nvm version` in zsh

Robert Shuford 2022-08-25 21:12:36 -04:00 committed by Jordan Harband
parent 8fd948001e
commit 4893128c61
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
1 changed files with 2 additions and 3 deletions

View File

@ -613,7 +613,6 @@ Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you e
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
@ -621,10 +620,10 @@ load-nvmrc() {
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi