mirror of
https://github.com/kremalicious/dotfiles.git
synced 2024-11-21 17:27:13 +01:00
run nvm use automatically in a directory with a .nvmrc file
This commit is contained in:
parent
5dee9e626d
commit
826f97c62b
32
exports
32
exports
@ -33,7 +33,35 @@ export CDPATH=$CDPATH:~/Code
|
|||||||
|
|
||||||
# nvm
|
# nvm
|
||||||
export NVM_DIR="$HOME/.nvm"
|
export NVM_DIR="$HOME/.nvm"
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||||
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||||
|
|
||||||
|
# Calling nvm use automatically in a directory with a .nvmrc file
|
||||||
|
# https://github.com/nvm-sh/nvm#zsh
|
||||||
|
autoload -U add-zsh-hook
|
||||||
|
|
||||||
|
load-nvmrc() {
|
||||||
|
local nvmrc_path
|
||||||
|
nvmrc_path="$(nvm_find_nvmrc)"
|
||||||
|
|
||||||
|
if [ -n "$nvmrc_path" ]; then
|
||||||
|
local nvmrc_node_version
|
||||||
|
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
|
||||||
|
|
||||||
|
if [ "$nvmrc_node_version" = "N/A" ]; then
|
||||||
|
nvm install
|
||||||
|
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
|
||||||
|
nvm use
|
||||||
|
fi
|
||||||
|
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
|
||||||
|
echo "Reverting to nvm default version"
|
||||||
|
nvm use default
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
add-zsh-hook chpwd load-nvmrc
|
||||||
|
load-nvmrc
|
||||||
|
|
||||||
|
|
||||||
# defer loading until needed for faster shell startup
|
# defer loading until needed for faster shell startup
|
||||||
#declare -a NODE_GLOBALS=(`find ~/.nvm/versions/node -maxdepth 3 -type l -wholename '*/bin/*' | xargs -n1 basename | sort | uniq`)
|
#declare -a NODE_GLOBALS=(`find ~/.nvm/versions/node -maxdepth 3 -type l -wholename '*/bin/*' | xargs -n1 basename | sort | uniq`)
|
||||||
@ -51,7 +79,7 @@ export NVM_DIR="$HOME/.nvm"
|
|||||||
#done
|
#done
|
||||||
|
|
||||||
# pip should only run if there is a virtualenv currently activated
|
# pip should only run if there is a virtualenv currently activated
|
||||||
export PIP_REQUIRE_VIRTUALENV=true
|
# export PIP_REQUIRE_VIRTUALENV=true
|
||||||
# cache pip-installed packages to avoid re-downloading
|
# cache pip-installed packages to avoid re-downloading
|
||||||
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache
|
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user