From 0de3b29fd3fde0d5d95271cb076a12931ccee7d8 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 19 Aug 2018 15:46:22 -0400 Subject: [PATCH] composer: Fix bin directory when Composer is not available (#6240) * Fix for Composer's bin when Composer isn't global When Composer isn't globally installed, the `composer global` call results in an error. This checks to see if Composer is available before making the call. When Composer isn't available, it will just manually set the directories. * Fix Composer brackets in global bin directory * composer: Apply feedback from ricpelo This applies ricpelo's feedback at https://github.com/robbyrussell/oh-my-zsh/pull/6240#pullrequestreview-64253321 * composer: Fix path check syntax * composer: test with $commands[] syntax --- plugins/composer/composer.plugin.zsh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index d00813e39..634961023 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -51,5 +51,10 @@ alias cgrm='composer global remove' # install composer in the current directory alias cget='curl -s https://getcomposer.org/installer | php' -# Add Composer's global binaries to PATH -export PATH=$PATH:$(composer global config bin-dir --absolute 2>/dev/null) +# Add Composer's global binaries to PATH, using Composer if available. +if (( $+commands[composer] )); then + export PATH=$PATH:$(composer global config bin-dir --absolute 2>/dev/null) +else + [ -d $HOME/.composer/vendor/bin ] && export PATH=$PATH:$HOME/.composer/vendor/bin + [ -d $HOME/.config/composer/vendor/bin ] && export PATH=$PATH:$HOME/.config/composer/vendor/bin +fi