mirror of
https://github.com/sorin-ionescu/prezto.git
synced 2025-01-23 11:32:17 +08:00
feat: Add Volta support to Node module
This commit is contained in:
parent
9626ce2beb
commit
6f38c9ce36
@ -8,19 +8,23 @@
|
|||||||
# Indrajit Raychaudhuri <irc@indrajit.com>
|
# Indrajit Raychaudhuri <irc@indrajit.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
# Possible lookup locations for manually installed nodenv and nvm.
|
# Possible lookup locations for manually installed version managers
|
||||||
local_nodenv_paths=({$NODENV_ROOT,{$XDG_CONFIG_HOME/,$HOME/.}nodenv}/bin/nodenv(N))
|
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))
|
local_nvm_paths=({$NVM_DIR,{$XDG_CONFIG_HOME/,$HOME/.}nvm}/nvm.sh(N))
|
||||||
|
local_volta_paths=({$VOLTA_HOME,$HOME/.volta}/bin/volta(N))
|
||||||
|
|
||||||
# Load manually installed or package manager installed nodenv into the shell
|
# Load manually installed or package manager installed nodenv into the shell
|
||||||
# session.
|
# session.
|
||||||
if (( $#local_nodenv_paths || $+commands[nodenv] )); then
|
if (( $#local_nodenv_paths || $+commands[nodenv] )); then
|
||||||
|
|
||||||
# Ensure manually installed nodenv is added to path when present.
|
# Ensure manually installed nodenv is added to path when present.
|
||||||
[[ -s $local_nodenv_paths[1] ]] && path=($local_nodenv_paths[1]:h $path)
|
[[ -s $local_nodenv_paths[1] ]] && path=($local_nodenv_paths[1]:h $path)
|
||||||
|
|
||||||
eval "$(nodenv init - zsh)"
|
eval "$(nodenv init - zsh)"
|
||||||
|
|
||||||
|
# Use volta if it's installed
|
||||||
|
elif (( $#local_volta_paths || $+commands[volta] )); then
|
||||||
|
export VOLTA_HOME="${VOLTA_HOME:-$HOME/.volta}"
|
||||||
|
path=("$VOLTA_HOME/bin" $path)
|
||||||
|
|
||||||
# Load manually installed nvm into the shell session.
|
# Load manually installed nvm into the shell session.
|
||||||
elif (( $#local_nvm_paths )); then
|
elif (( $#local_nvm_paths )); then
|
||||||
source "$local_nvm_paths[1]" --no-use
|
source "$local_nvm_paths[1]" --no-use
|
||||||
@ -31,7 +35,7 @@ elif (( $+commands[brew] )) \
|
|||||||
source "$nvm_path/nvm.sh" --no-use
|
source "$nvm_path/nvm.sh" --no-use
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset local_n{odenv,vm}_paths nvm_path
|
unset local_{nodenv,nvm,volta}_paths nvm_path
|
||||||
|
|
||||||
# Return if requirements are not found.
|
# Return if requirements are not found.
|
||||||
if (( ! $+commands[node] && ! $#functions[(i)n(odenv|vm)] )); then
|
if (( ! $+commands[node] && ! $#functions[(i)n(odenv|vm)] )); then
|
||||||
@ -64,4 +68,12 @@ if ! zstyle -t ':prezto:module:node:alias' skip; then
|
|||||||
alias npmci='npm ci'
|
alias npmci='npm ci'
|
||||||
alias npmcit='npm cit'
|
alias npmcit='npm cit'
|
||||||
alias npmit='npm it'
|
alias npmit='npm it'
|
||||||
fi
|
|
||||||
|
# Add Volta-specific aliases if Volta is installed
|
||||||
|
if (( $+commands[volta] )); then
|
||||||
|
alias vl='volta list'
|
||||||
|
alias vla='volta list all'
|
||||||
|
alias vi='volta install'
|
||||||
|
alias vp='volta pin'
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user