Create syntax.sh

This commit is contained in:
Dennis Eichhorn 2017-09-25 12:59:04 +02:00 committed by GitHub
parent 2610ca4475
commit 1f2e919e32

12
Hooks/syntax.sh Normal file
View File

@ -0,0 +1,12 @@
git diff --cached --name-only | while read FILE; do
if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then
# Courtesy of swytsh from the comments below.
if [[ -f $FILE ]]; then
php -l "$FILE" 1> /dev/null
if [ $? -ne 0 ]; then
echo -e "\e[1;31m\tAborting commit due to files with syntax errors.\e[0m" >&2
exit 1
fi
fi
fi
done || exit $?