-
-
Save dmgig/758e1f7cbbfbdde6e36db9b4623318fe to your computer and use it in GitHub Desktop.
Recursive PHP Lint script (git tracked files only)
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 | |
# php linter of git tracked files | |
# passing --success argument will print no-error files in the list, | |
# otherwise, only files with parse errors will be displayed. | |
IFS=$'\n' #split filenames at newlines only | |
for file in `git ls-tree -r master --name-only` | |
do | |
EXTENSION="${file##*.}" | |
if [ "$EXTENSION" == "php" ] || [ "$EXTENSION" == "phtml" ] | |
then | |
RESULTS=`php -l $file` | |
if [ "$RESULTS" == "No syntax errors detected in $file" ] | |
then | |
if [ -n "$1" ] | |
then | |
printf '\e[32m%s\e[0m\n' "${RESULTS}" | |
fi | |
else | |
printf '\e[31m%s\e[0m\n' "${RESULTS}" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lint git tracked files only, add some color for success and failure.