Skip to content

Commit

Permalink
Support composer bin dir in helpers/locate.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Sep 12, 2022
1 parent 07027f5 commit a9442f6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pre_commit_hooks/helpers/locate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit a9442f6

Please sign in to comment.