609890847d3e3b222431952ee7be99803bd16ccc
- Author
- Marc Cornellà <marc.cornella@live.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
npm: hardcode completion function and delete cached one (#8679)
Fixes #8665
Diff
1diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh
2index f62174a4f42c482c488571de293b6eea2e3bfdb2..87c68f3fb091c0215ad77b59f7609543b3342e85 100644
3--- a/plugins/npm/npm.plugin.zsh
4+++ b/plugins/npm/npm.plugin.zsh
5@@ -1,14 +1,16 @@
6 (( $+commands[npm] )) && {
7- __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion"
8-
9- if [[ ! -f $__NPM_COMPLETION_FILE ]]; then
10- npm completion >! $__NPM_COMPLETION_FILE 2>/dev/null
11- [[ $? -ne 0 ]] && rm -f $__NPM_COMPLETION_FILE
12- fi
13-
14- [[ -f $__NPM_COMPLETION_FILE ]] && source $__NPM_COMPLETION_FILE
15-
16- unset __NPM_COMPLETION_FILE
17+ rm -f "${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion"
18+
19+ _npm_completion() {
20+ local si=$IFS
21+ compadd -- $(COMP_CWORD=$((CURRENT-1)) \
22+ COMP_LINE=$BUFFER \
23+ COMP_POINT=0 \
24+ npm completion -- "${words[@]}" \
25+ 2>/dev/null)
26+ IFS=$si
27+ }
28+ compdef _npm_completion npm
29 }
30
31 # Install dependencies globally