Skip to content

Commit

Permalink
pre-commit hook does not work with alias
Browse files Browse the repository at this point in the history
In some workflows like  MAMP on OSX default php version is set using alias in bash profile

alias php='/Applications/MAMP/bin/php/php7.4.2/bin/php -c "/Library/Application Support/appsolute/MAMP PRO/conf/php7.4.2.ini"'

In such case when phpstan and codesniffer are executed via git hoot it will run them using the default system php instead of using the alias.

Prefixing the method call with php triggers the alias and solves the issue.
  • Loading branch information
najdanovicivan committed Nov 17, 2020
1 parent d63020b commit e111f04
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions admin/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if [ "$FILES" != "" ]
then
echo "Running PHPStan..."
# Run on whole codebase
./vendor/bin/phpstan analyse
php ./vendor/bin/phpstan analyse

if [ $? != 0 ]
then
Expand All @@ -47,7 +47,7 @@ fi
if [ "$FILES" != "" ]
then
echo "Running Code Sniffer..."
./vendor/bin/phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 --encoding=utf-8 -n -p $FILES
php ./vendor/bin/phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 --encoding=utf-8 -n -p $FILES
fi

exit $?

0 comments on commit e111f04

Please sign in to comment.