From 007fd93fd71d6bcb12a0a688f47c9e9f58fdbaff Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Tue, 27 Sep 2016 21:09:12 +0100 Subject: [PATCH] Make sure we have binaries before trying to format them Otherwise basename spits out errors #8 --- zsh-nvm.plugin.zsh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/zsh-nvm.plugin.zsh b/zsh-nvm.plugin.zsh index 7db9d6d..7222d57 100644 --- a/zsh-nvm.plugin.zsh +++ b/zsh-nvm.plugin.zsh @@ -23,10 +23,17 @@ _zsh_nvm_install() { } _zsh_nvm_global_binaries() { - echo "$NVM_DIR"/v0*/bin/*(N) "$NVM_DIR"/versions/*/*/bin/*(N) | - xargs -n 1 basename | - sort | - uniq + + # Look for global binaries + local global_binary_paths=$(echo "$NVM_DIR"/v0*/bin/*(N) "$NVM_DIR"/versions/*/*/bin/*(N)) + + # If we have some, format them + if [[ -n "$global_binary_paths" ]]; then + echo "$NVM_DIR"/v0*/bin/*(N) "$NVM_DIR"/versions/*/*/bin/*(N) | + xargs -n 1 basename | + sort | + uniq + fi } _zsh_nvm_load() {