summaryrefslogtreecommitdiff
path: root/plugins/npm/npm.plugin.zsh
diff options
context:
space:
mode:
authorPhilipp Wahala <philipp.wahala@gmail.com>2016-02-29 10:16:26 +0100
committerMarc Cornellà <marc.cornella@live.com>2016-08-22 16:17:34 +0200
commit7c1ca0e4d85e0de75a3eb8c23b4e799454e0f390 (patch)
tree335315f75500f37e80d30912d5c4c8cd1fee2c3b /plugins/npm/npm.plugin.zsh
parent4b9772fffecf15f293881db0bd1432bfda270055 (diff)
downloadzsh-7c1ca0e4d85e0de75a3eb8c23b4e799454e0f390.tar.gz
zsh-7c1ca0e4d85e0de75a3eb8c23b4e799454e0f390.tar.bz2
zsh-7c1ca0e4d85e0de75a3eb8c23b4e799454e0f390.zip
Create and cache npm completion on first run
Signed-off-by: Marc Cornellà <marc.cornella@live.com>
Diffstat (limited to 'plugins/npm/npm.plugin.zsh')
-rw-r--r--plugins/npm/npm.plugin.zsh8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh
index 422d81ceb..ec595e74d 100644
--- a/plugins/npm/npm.plugin.zsh
+++ b/plugins/npm/npm.plugin.zsh
@@ -1,4 +1,10 @@
-eval "$(npm completion 2>/dev/null)"
+__NPM_COMPLETION_FILE="${ZSH_CACHE_DIR}/npm_completion"
+
+if [[ ! -f $__NPM_COMPLETION_FILE ]]; then
+ npm completion >! $__NPM_COMPLETION_FILE || rm -f $__NPM_COMPLETION_FILE
+fi
+
+source $__NPM_COMPLETION_FILE
# Install dependencies globally
alias npmg="npm i -g "