1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2025-07-04 09:59:25 +00:00

node: Prefer nodenv over nvm when available

Reverse `nodenv` vs `nvm` selection order, preferring `nodenv` instead.

For additional rationale, see: https://github.com/nodenv/nodenv/wiki/Why-nodenv%3F
This commit is contained in:
Indrajit Raychaudhuri
2021-05-16 20:11:48 -05:00
committed by Indrajit Raychaudhuri
parent af46875c5e
commit f84075b8d4
3 changed files with 29 additions and 29 deletions

View File

@ -8,11 +8,21 @@
#
# Possible lookup locations.
local_nvm_paths=({$NVM_DIR,{$XDG_CONFIG_HOME/,$HOME/.}nvm}/nvm.sh(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))
# 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)"
# Load manually installed NVM into the shell session.
if [[ -s ${local_nvm::=$local_nvm_paths[1]} ]]; then
elif [[ -s ${local_nvm::=$local_nvm_paths[1]} ]]; then
source "$local_nvm --no-use"
unset local_nvm{,_paths}
@ -22,16 +32,6 @@ elif (( $+commands[brew] )) \
source "$nvm_prefix/nvm.sh --no-use"
unset nvm_prefix
# Load manually installed nodenv into the shell session.
elif [[ -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)"
# Return if requirements are not found.
elif (( ! $+commands[node] )); then
return 1