Last active
November 14, 2017 14:31
-
-
Save edwint88/6100e61be9d230f58ce1c2feb5c820c7 to your computer and use it in GitHub Desktop.
Using PHP CS Fixer on CI with Mercurial
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/bash | |
CHANGED_FILES=$(hg status -m -a -n | grep "**.php$" | grep -v "vendor"); | |
printf "Files to be checked:\n\n"; | |
echo "$CHANGED_FILES"; | |
printf "\n" | |
if [[ -n "$CHANGED_FILES" ]] | |
then | |
EXTRA_ARGS=('--' ${CHANGED_FILES[@]}); | |
printf "=============>>> START execute php-cs-fixer <<<=============\n\n"; | |
RESULT=$(vendor-ci/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no "${EXTRA_ARGS[@]}"); | |
echo "$RESULT"; | |
printf "=============>>> FINISH execute php-cs-fixer <<<=============\n\n"; | |
if [[ $RESULT == *"1)"* ]]; then | |
printf "=============>>> Files are NOT well FORMATTED! <<<=============\n\n"; | |
exit 1; | |
fi | |
else | |
echo "NO Files were changed!"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment