From 136a83433ad5214eb3d5a0ca3c799be8fc9cb1aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 23 Aug 2016 09:31:29 +0200 Subject: [PATCH] npm: only load completion if npm exists --- plugins/npm/npm.plugin.zsh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index ec595e74..480e92a9 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -1,8 +1,10 @@ -__NPM_COMPLETION_FILE="${ZSH_CACHE_DIR}/npm_completion" +(( $+commands[npm] )) && { + __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 + if [[ ! -f $__NPM_COMPLETION_FILE ]]; then + npm completion >! $__NPM_COMPLETION_FILE || rm -f $__NPM_COMPLETION_FILE + fi +} source $__NPM_COMPLETION_FILE