1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-07-03 14:40:27 +00:00
prezto/modules/node/init.zsh

46 lines
1.3 KiB
Bash
Raw Normal View History

2012-02-01 04:37:51 +00:00
#
# Configures Node local installation, loads version managers, and defines
# variables and aliases.
2012-02-01 04:37:51 +00:00
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
2012-12-13 15:10:55 +00:00
# Zeh Rizzatti <zehrizzatti@gmail.com>
# Indrajit Raychaudhuri <irc@indrajit.com>
2012-02-01 04:37:51 +00:00
#
# 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)"
2014-10-13 15:57:20 +00:00
# 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}
2014-10-13 15:57:20 +00:00
# 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
2012-12-13 15:10:55 +00:00
2012-07-23 19:00:44 +00:00
# Return if requirements are not found.
elif (( ! $+commands[node] )); then
2012-07-04 01:38:56 +00:00
return 1
fi
#
# Variables
#
N_PREFIX="${XDG_CONFIG_HOME:-$HOME/.config}/n" # The path to 'n' cache.