1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-23 00:17:59 +00:00
prezto/modules/node/init.zsh

68 lines
1.8 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 for manually installed nodenv and nvm.
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 or package manager installed nodenv into the shell
# session.
if (( $#local_nodenv_paths || $+commands[nodenv] )); then
# Ensure manually installed nodenv is added to path when present.
[[ -s $local_nodenv_paths[1] ]] && path=($local_nodenv_paths[1]:h $path)
eval "$(nodenv init - zsh)"
2014-10-13 15:57:20 +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.
elif (( $+commands[brew] )) \
&& [[ -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.
if (( ! $+commands[node] && ! $#functions[(i)n(odenv|vm)] )); 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.
#
# Aliases
#
if ! zstyle -t ':prezto:module:node:alias' skip; then
# 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'
fi