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-13 20:37:46 +00:00
|
|
|
# Possible lookup locations.
|
|
|
|
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))
|
|
|
|
|
|
|
|
# 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)"
|
2021-05-13 20:37:46 +00:00
|
|
|
|
2014-10-13 15:57:20 +00:00
|
|
|
# Load manually installed NVM into the shell session.
|
2021-05-17 01:11:48 +00:00
|
|
|
elif [[ -s ${local_nvm::=$local_nvm_paths[1]} ]]; then
|
2021-05-24 14:04:19 +00:00
|
|
|
source "$local_nvm" --no-use
|
2021-05-13 20:37:46 +00:00
|
|
|
unset local_nvm{,_paths}
|
2014-10-13 15:57:20 +00:00
|
|
|
|
|
|
|
# Load package manager installed NVM into the shell session.
|
2021-05-13 20:37:46 +00:00
|
|
|
elif (( $+commands[brew] )) \
|
|
|
|
&& [[ -d "${nvm_prefix::="$(brew --prefix nvm 2> /dev/null)"}" ]]; then
|
2021-05-24 14:04:19 +00:00
|
|
|
source "$nvm_prefix/nvm.sh" --no-use
|
2018-12-13 04:17:16 +00:00
|
|
|
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.
|
2015-02-24 20:29:25 +00:00
|
|
|
elif (( ! $+commands[node] )); 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'
|