mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-22 20:57:59 +00:00
node: Cache completion for additional helpers
Add support for npm and additional well-known helper commands
This commit is contained in:
parent
e7fea3343f
commit
a2398fc045
@ -28,18 +28,28 @@ elif (( ! $+commands[node] )); then
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load NPM completion.
|
# Load NPM and known helper completions.
|
||||||
if (( $+commands[npm] )); then
|
typeset -A compl_commands=(
|
||||||
cache_file="${TMPDIR:-/tmp}/prezto-node-cache.$UID.zsh"
|
npm 'npm completion'
|
||||||
|
grunt 'grunt --completion=zsh'
|
||||||
|
gupl 'gulp --completion=zsh'
|
||||||
|
)
|
||||||
|
|
||||||
if [[ "$commands[npm]" -nt "$cache_file" \
|
for compl_command in "${(k)compl_commands[@]}"; do
|
||||||
|| "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \
|
if (( $+commands[$compl_command] )); then
|
||||||
|| ! -s "$cache_file" ]]; then
|
cache_file="${TMPDIR:-/tmp}/prezto-$compl_command-cache.$UID.zsh"
|
||||||
# npm is slow; cache its output.
|
|
||||||
npm completion >! "$cache_file" 2> /dev/null
|
# Completion commands are slow; cache their output if old or missing.
|
||||||
|
if [[ "$commands[$compl_command]" -nt "$cache_file" \
|
||||||
|
|| "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \
|
||||||
|
|| ! -s "$cache_file" ]]; then
|
||||||
|
command ${=compl_commands[$compl_command]} >! "$cache_file" 2> /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
source "$cache_file"
|
||||||
|
|
||||||
|
unset cache_file
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
source "$cache_file"
|
unset compl_command{s,}
|
||||||
|
|
||||||
unset cache_file
|
|
||||||
fi
|
|
||||||
|
Loading…
Reference in New Issue
Block a user