Skip to content

Commit

Permalink
Add linting as suggested by @jrbasso
Browse files Browse the repository at this point in the history
  • Loading branch information
jadb committed Mar 31, 2015
1 parent b237f5f commit 7977159
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions contrib/pre-commit
@@ -1,5 +1,6 @@
#!/bin/sh
FILES=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
PROJECT=`php -r "echo dirname(dirname(realpath('$0')));"`

# Determine if a file list is passed
if [ "$#" -eq 1 ]
Expand All @@ -12,7 +13,19 @@ then
fi
SFILES=${SFILES:-$FILES}

if [ "$FILES" != "" ]
echo "Checking PHP Lint..."
for FILE in $SFILES
do
php -l -d display_errors=0 $PROJECT/$FILE
if [ $? != 0 ]
then
echo "Fix the error before commit."
exit 1
fi
FILES="$FILES $PROJECT/$FILE"
done

if [ "$SFILES" != "" ]
then
echo "Running PHPCS"
./vendor/bin/phpcs --standard=vendor/cakephp/cakephp-codesniffer/CakePHP $SFILES
Expand All @@ -22,4 +35,4 @@ then
exit 1
fi
fi
exit $?
exit $?

0 comments on commit 7977159

Please sign in to comment.