WordPress-Coding-Standards/bin/pre-commit

14 lines
488 B
Bash
Executable file

#!/bin/bash
set -e
cd "$(git rev-parse --show-toplevel)"
phpcs_root="$(dirname $(dirname $(which phpcs)))"
if [ -z "$phpcs_root" ] || [ ! -d "$phpcs_root" ] || [ ! -e "$phpcs_root/tests/AllTests.php" ]; then
echo "Unable to locate phpcs on path to locate the root of the PHP_CodeSniffer project" 1>&2
exit 1
fi
find . \( -name '*.php' \) -exec php -lf {} \;
PHPCS_DIR=$phpcs_root phpunit --bootstrap="./Test/phpcs3-bootstrap.php" --filter WordPress "$phpcs_root/tests/AllTests.php"