diff --git a/README.md b/README.md index d71451c..07c9199 100644 --- a/README.md +++ b/README.md @@ -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