I have a git hook that looks something like this:
PHPCS_BIN=vendor/bin/phpcs
...
OUTPUT=$($PHPCS_BIN $STAGED_FILES)
RETVAL=$?
exit $RETVAL
Before many switched to docker, everything was fine, since everyone had php installed on their operating systems.
Now, some people, have php installed inside docker and calling vendor/bin/phpcs does not work. They change line PHPCS_BIN=vendor/bin/phpcs
to PHPCS_BIN="docker exec php /var/www/vendor/bin/phpcs"
.
Perhaps someone knows the secret best practices how to solve this problem?
Now, this hook is installed with a special command(composer install-hooks
) that simply copies the contents of the file from the project to the .git/hooks folder.
I'm thinking to add some interactivity to this command and let the developer decide how to call phpcs.
I also thought about using this utility: https://pre-commit.com
Although I'm not sure if it will solve the problem