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!
|
# place this after nvm initialization!
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
load-nvmrc() {
|
load-nvmrc() {
|
||||||
if [[ -f .nvmrc && -r .nvmrc ]]; then
|
local node_version="$(nvm version)"
|
||||||
nvm use
|
local nvmrc_path="$(nvm_find_nvmrc)"
|
||||||
elif [[ $(nvm version) != $(nvm version default) ]]; then
|
|
||||||
|
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"
|
echo "Reverting to nvm default version"
|
||||||
nvm use default
|
nvm use default
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue