diff --git a/pre_commit_hooks/helpers/locate.sh b/pre_commit_hooks/helpers/locate.sh index 464e12e..6c7e76e 100644 --- a/pre_commit_hooks/helpers/locate.sh +++ b/pre_commit_hooks/helpers/locate.sh @@ -10,7 +10,12 @@ exec_command="" # A phar file will need to be called by php prefixed_local_command="php $local_command" -if [ -f "$vendor_command" ]; then +# Path of composer bin dir +composer_bin_dir=$(composer config bin-dir 2>/dev/null) + +if [ -n $composer_bin_dir ] && [ -f "$composer_bin_dir/$global_command" ]; then + exec_command="$composer_bin_dir/$global_command" +elif [ -f "$vendor_command" ]; then exec_command=$vendor_command elif hash $global_command 2>/dev/null; then exec_command=$global_command @@ -19,6 +24,9 @@ elif [ -f "$local_command" ]; then else echo -e "${bldred}No valid ${title} found!${txtrst}" echo "Please have one available as one of the following:" + if [ -n $composer_bin_dir ]; then + echo " * $composer_bin_dir/$global_command" + fi echo " * $local_command" echo " * $vendor_command" echo " * $global_command"