2012-02-01 04:37:51 +00:00
|
|
|
#
|
2021-05-13 20:37:46 +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>
|
2021-05-15 19:59:31 +00:00
|
|
|
# Indrajit Raychaudhuri <irc@indrajit.com>
|
2012-02-01 04:37:51 +00:00
|
|
|
#
|
|
|
|
|
2021-05-26 05:21:35 +00:00
|
|
|
# Possible lookup locations for manually installed nodenv and nvm.
|
2021-05-13 20:37:46 +00:00
|
|
|
local_nodenv_paths=({$NODENV_ROOT,{$XDG_CONFIG_HOME/,$HOME/.}nodenv}/bin/nodenv(N))
|
2021-05-17 01:11:48 +00:00
|
|
|
local_nvm_paths=({$NVM_DIR,{$XDG_CONFIG_HOME/,$HOME/.}nvm}/nvm.sh(N))
|
|
|
|
|
2021-05-26 05:21:35 +00:00
|
|
|
# Load manually installed or package manager installed nodenv into the shell
|
|
|
|
# session.
|
|
|
|
if (( $#local_nodenv_paths || $+commands[nodenv] )); then
|
2021-05-17 01:11:48 +00:00
|
|
|
|
2021-05-26 05:21:35 +00:00
|
|
|
# Ensure manually installed nodenv is added to path when present.
|
|
|
|
[[ -s $local_nodenv_paths[1] ]] && path=($local_nodenv_paths[1]:h $path)
|
2021-05-13 20:37:46 +00:00
|
|
|
|
2021-05-26 05:21:35 +00:00
|
|
|
eval "$(nodenv init - zsh)"
|
2014-10-13 15:57:20 +00:00
|
|
|
|
2021-05-26 05:21:35 +00:00
|
|
|
# Load manually installed nvm into the shell session.
|
|
|
|
elif (( $#local_nvm_paths )); then
|
|
|
|
source "$local_nvm_paths[1]" --no-use
|
|
|
|
|
|
|
|
# Load package manager installed nvm into the shell session.
|
2021-05-13 20:37:46 +00:00
|
|
|
elif (( $+commands[brew] )) \
|
2021-05-26 05:21:35 +00:00
|
|
|
&& [[ -d "${nvm_path::="$(brew --prefix 2> /dev/null)"/opt/nvm}" ]]; then
|
|
|
|
source "$nvm_path/nvm.sh" --no-use
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset local_n{odenv,vm}_paths nvm_path
|
2012-12-13 15:10:55 +00:00
|
|
|
|
2012-07-23 19:00:44 +00:00
|
|
|
# Return if requirements are not found.
|
2021-05-26 05:21:35 +00:00
|
|
|
if (( ! $+commands[node] && ! $#functions[(i)n(odenv|vm)] )); then
|
2012-07-04 01:38:56 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2021-05-17 03:04:27 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Variables
|
|
|
|
#
|
|
|
|
|
|
|
|
N_PREFIX="${XDG_CONFIG_HOME:-$HOME/.config}/n" # The path to 'n' cache.
|
2021-05-17 03:05:27 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Aliases
|
|
|
|
#
|
|
|
|
|
|
|
|
# npm
|
|
|
|
alias npmi='npm install'
|
|
|
|
alias npml='npm list'
|
|
|
|
alias npmo='npm outdated'
|
|
|
|
alias npmp='npm publish'
|
|
|
|
alias npmP='npm prune'
|
|
|
|
alias npmr='npm run'
|
|
|
|
alias npms='npm search'
|
|
|
|
alias npmt='npm test'
|
|
|
|
alias npmu='npm update'
|
|
|
|
alias npmx='npm uninstall'
|
|
|
|
|
|
|
|
alias npmci='npm ci'
|
|
|
|
alias npmcit='npm cit'
|
|
|
|
alias npmit='npm it'
|