accerlate nvm invoke when change directory
parent
4b88613508
commit
a338f98a5a
|
@ -316,9 +316,16 @@ 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() {
|
||||
if [[ -f .nvmrc && -r .nvmrc ]]; then
|
||||
nvm use
|
||||
elif [[ $(nvm version) != $(nvm version default) ]]; then
|
||||
local node_version="$(nvm version)"
|
||||
local nvmrc_path="$(nvm_find_nvmrc)"
|
||||
|
||||
if [ -n "$nvmrc_path" ]; then
|
||||
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
|
||||
|
||||
if [ "$nvmrc_node_version" != "N/A" ] && [ "$nvmrc_node_version" != "$node_version" ]; then
|
||||
nvm use
|
||||
fi
|
||||
elif [ "$node_version" != "$(nvm version default)" ]; then
|
||||
echo "Reverting to nvm default version"
|
||||
nvm use default
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue