mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 14:21:50 +00:00
[readme] optimize calling of nvm version
in zsh
This commit is contained in:
parent
8fd948001e
commit
4893128c61
@ -613,7 +613,6 @@ Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you e
|
|||||||
# place this after nvm initialization!
|
# place this after nvm initialization!
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
load-nvmrc() {
|
load-nvmrc() {
|
||||||
local node_version="$(nvm version)"
|
|
||||||
local nvmrc_path="$(nvm_find_nvmrc)"
|
local nvmrc_path="$(nvm_find_nvmrc)"
|
||||||
|
|
||||||
if [ -n "$nvmrc_path" ]; then
|
if [ -n "$nvmrc_path" ]; then
|
||||||
@ -621,10 +620,10 @@ load-nvmrc() {
|
|||||||
|
|
||||||
if [ "$nvmrc_node_version" = "N/A" ]; then
|
if [ "$nvmrc_node_version" = "N/A" ]; then
|
||||||
nvm install
|
nvm install
|
||||||
elif [ "$nvmrc_node_version" != "$node_version" ]; then
|
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
|
||||||
nvm use
|
nvm use
|
||||||
fi
|
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"
|
echo "Reverting to nvm default version"
|
||||||
nvm use default
|
nvm use default
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user