From 86fe4fdae386e171f80ba03da529e5a97d8df75c Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Sat, 2 Jul 2016 13:52:54 +0100 Subject: [PATCH] Check if we have any cached modules before reccomending them --- zsh-better-npm-completion.plugin.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/zsh-better-npm-completion.plugin.zsh b/zsh-better-npm-completion.plugin.zsh index 6fcb4ef..7f39264 100644 --- a/zsh-better-npm-completion.plugin.zsh +++ b/zsh-better-npm-completion.plugin.zsh @@ -6,6 +6,10 @@ _zbnc_no_of_npm_args() { echo "$#words" } +_zbnc_list_cached_modules() { + ls ~/.npm +} + _zbnc_recursively_look_for() { local filename="$1" local dir=$PWD @@ -31,8 +35,11 @@ _zbnc_npm_install_completion() { # Only run on `npm install ?` [[ ! "$(_zbnc_no_of_npm_args)" = "3" ]] && return - # Reccomend cached modules - _values $(ls ~/.npm) + # Return if we don't have any cahced modules + [[ "$(_zbnc_list_cached_modules)" = "" ]] && return + + # If we do, reccomend them + _values $(_zbnc_list_cached_modules) # Make sure we don't run default completion custom_completion=true