summaryrefslogtreecommitdiff
path: root/plugins/nvm
diff options
context:
space:
mode:
authorCarlo Sala <carlosalag@protonmail.com>2023-12-27 10:52:23 +0100
committerCarlo Sala <carlosalag@protonmail.com>2023-12-27 10:52:23 +0100
commit8a8a04f43a23f9d3f25b941293d0e9be1d3e301c (patch)
tree7507de1b64da86390100de5688262c7933f8c846 /plugins/nvm
parentf74add6cb215b55722f9e64273be82d7bae5014e (diff)
downloadzsh-8a8a04f43a23f9d3f25b941293d0e9be1d3e301c.tar.gz
zsh-8a8a04f43a23f9d3f25b941293d0e9be1d3e301c.tar.bz2
zsh-8a8a04f43a23f9d3f25b941293d0e9be1d3e301c.zip
fix(nvm): prevent duplicates in lazy_cmd
Closes #11344
Diffstat (limited to 'plugins/nvm')
-rw-r--r--plugins/nvm/nvm.plugin.zsh9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
index 1badbeab5..94b666175 100644
--- a/plugins/nvm/nvm.plugin.zsh
+++ b/plugins/nvm/nvm.plugin.zsh
@@ -24,9 +24,14 @@ if zstyle -t ':omz:plugins:nvm' lazy && \
! zstyle -t ':omz:plugins:nvm' autoload; then
# Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd
zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd
+ nvm_lazy_cmd=(nvm node npm npx pnpm yarn $nvm_lazy_cmd) # default values
eval "
- function nvm node npm npx pnpm yarn $nvm_lazy_cmd {
- unfunction nvm node npm npx pnpm yarn $nvm_lazy_cmd
+ function $nvm_lazy_cmd {
+ for func in $nvm_lazy_cmd; do
+ if (( \$+functions[\$func] )); then
+ unfunction \$func
+ fi
+ done
# Load nvm if it exists in \$NVM_DIR
[[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\"
\"\$0\" \"\$@\"