Last active
April 20, 2017 07:57
-
-
Save cakper/fbfae9e1acc68b1e560b to your computer and use it in GitHub Desktop.
GIT pre-commit PHPSpec & PHP-CS-Fixer hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| CWD=$(pwd) | |
| STATUS=0 | |
| echo "Running PHPSpec and PHPCS" | |
| if [ -f $CWD/bin/phpspec ] | |
| then | |
| $CWD/bin/phpspec run --quiet | |
| if [ $? -ne 0 ] | |
| then | |
| echo "PHPSpec has failed - commit aborted" | |
| STATUS=1 | |
| fi | |
| fi | |
| if [ -f $CWD/bin/php-cs-fixer ] | |
| then | |
| $CWD/bin/php-cs-fixer fix --quiet --dry-run src | |
| if [ $? -ne 0 ] | |
| then | |
| echo "PHPCS for src/ has failed - commit aborted" | |
| STATUS=1 | |
| fi | |
| $CWD/bin/php-cs-fixer fix --quiet --fixers=-visibility --dry-run spec | |
| if [ $? -ne 0 ] | |
| then | |
| echo "PHPCS for spec/ has failed - commit aborted" | |
| STATUS=1 | |
| fi | |
| $CWD/bin/php-cs-fixer fix --quiet --dry-run features | |
| if [ $? -ne 0 ] | |
| then | |
| echo "PHPCS for features/ has failed - commit aborted" | |
| STATUS=1 | |
| fi | |
| fi | |
| exit $STATUS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment