From 7c1ca0e4d85e0de75a3eb8c23b4e799454e0f390 Mon Sep 17 00:00:00 2001 From: Philipp Wahala Date: Mon, 29 Feb 2016 10:16:26 +0100 Subject: [PATCH] Create and cache npm completion on first run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc Cornellà --- plugins/npm/npm.plugin.zsh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 "