You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
# |
|
# Configures Node local installation, loads version managers, and defines |
|
# variables and aliases. |
|
# |
|
# Authors: |
|
# Sorin Ionescu <sorin.ionescu@gmail.com> |
|
# Zeh Rizzatti <zehrizzatti@gmail.com> |
|
# Indrajit Raychaudhuri <irc@indrajit.com> |
|
# |
|
|
|
# Possible lookup locations. |
|
local_nodenv_paths=({$NODENV_ROOT,{$XDG_CONFIG_HOME/,$HOME/.}nodenv}/bin/nodenv(N)) |
|
local_nvm_paths=({$NVM_DIR,{$XDG_CONFIG_HOME/,$HOME/.}nvm}/nvm.sh(N)) |
|
|
|
# Load manually installed nodenv into the shell session. |
|
if [[ -s ${local_nodenv::=$local_nodenv_paths[1]} ]]; then |
|
path=("$local_nodenv:h" $path) |
|
eval "$(nodenv init - --no-rehash zsh)" |
|
unset local_nodenv{,_paths} |
|
|
|
# Load package manager installed nodenv into the shell session. |
|
elif (( $+commands[nodenv] )); then |
|
eval "$(nodenv init - --no-rehash zsh)" |
|
|
|
# Load manually installed NVM into the shell session. |
|
elif [[ -s ${local_nvm::=$local_nvm_paths[1]} ]]; then |
|
source "$local_nvm --no-use" |
|
unset local_nvm{,_paths} |
|
|
|
# Load package manager installed NVM into the shell session. |
|
elif (( $+commands[brew] )) \ |
|
&& [[ -d "${nvm_prefix::="$(brew --prefix nvm 2> /dev/null)"}" ]]; then |
|
source "$nvm_prefix/nvm.sh --no-use" |
|
unset nvm_prefix |
|
|
|
# Return if requirements are not found. |
|
elif (( ! $+commands[node] )); then |
|
return 1 |
|
fi
|
|
|