check for nvmrc and switch node version

if a .nvmrc file exists in a directory, read it to change node to the correct version
Also ignore this file globally from git repos
This commit is contained in:
Nick Nisi
2016-04-26 10:32:31 -05:00
parent a5289bd799
commit 1065a7a5f6
2 changed files with 11 additions and 1 deletions

View File

@@ -18,3 +18,6 @@ Icon
# typescript command garbage # typescript command garbage
tscommand*.txt tscommand*.txt
# nvm - the Node Version Manager
.nvmrc

View File

@@ -21,7 +21,7 @@ fi
# initialize autocomplete # initialize autocomplete
autoload -U compinit autoload -U compinit add-zsh-hook
compinit compinit
for config ($ZSH/**/*completion.sh) source $config for config ($ZSH/**/*completion.sh) source $config
@@ -63,6 +63,13 @@ fi
# source nvm # source nvm
export NVM_DIR=~/.nvm export NVM_DIR=~/.nvm
load-nvmrc() {
if [[ -f .nvmrc && -r .nvmrc ]]; then
nvm use
fi
}
add-zsh-hook chpwd load-nvmrc
if hash brew 2>/dev/null; then if hash brew 2>/dev/null; then
source $(brew --prefix nvm)/nvm.sh source $(brew --prefix nvm)/nvm.sh
source `brew --prefix`/etc/profile.d/z.sh source `brew --prefix`/etc/profile.d/z.sh