1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-11 00:10:08 +00:00

fix(nvm): prevent duplicates in lazy_cmd

Closes #11344
This commit is contained in:
Carlo Sala 2023-12-27 10:52:23 +01:00
parent f74add6cb2
commit 8a8a04f43a
No known key found for this signature in database
GPG key ID: DA6FB450C1A4FE9A

View file

@ -24,9 +24,14 @@ if zstyle -t ':omz:plugins:nvm' lazy && \
! zstyle -t ':omz:plugins:nvm' autoload; then ! zstyle -t ':omz:plugins:nvm' autoload; then
# Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd # 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 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 " eval "
function nvm node npm npx pnpm yarn $nvm_lazy_cmd { function $nvm_lazy_cmd {
unfunction nvm node npm npx pnpm yarn $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 # Load nvm if it exists in \$NVM_DIR
[[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\" [[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\"
\"\$0\" \"\$@\" \"\$0\" \"\$@\"