Adding watch for .nvmrc

In the event that .nvmrc is found in a directory, change to that version of node using NVM.
This commit is contained in:
Jeffery Bennett 2017-06-20 23:32:58 -05:00 committed by GitHub
parent 1c958e02a5
commit 49fe92d05b

View File

@ -3,3 +3,15 @@
# Load nvm if it exists
[[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
# Look for .nvmrc in directories. If found, change to that version of node.
autoload -Uz add-zsh-hook
load-nvmrc() {
if [[ -f .nvmrc && -r .nvmrc ]]; then
nvm use --delete-prefix
elif [[ -f package.json && -r package.json ]]; then
nvm use --delete-prefix v6.11.1
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc