Created
November 5, 2021 10:38
-
-
Save kovshenin/d6fd8f3255eb36fca006bbda22ff4c5e to your computer and use it in GitHub Desktop.
Pre-deploy hook for Sail CLI
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 | |
FILES=`sail diff --raw | grep \.php$` | |
ROOT="$(dirname `dirname $0`)" | |
EXIST='' | |
for FILE in $FILES | |
do | |
if [ -f "$ROOT/$FILE" ]; then | |
EXIST="$EXIST $ROOT/$FILE" | |
fi | |
done | |
FILES=$EXIST | |
echo "- Linting PHP files" | |
for FILE in $FILES | |
do | |
php -l "$FILE" 1>/dev/null | |
if [ $? != 0 ]; then | |
exit 1 | |
fi | |
done | |
if [ "$FILES" != "" ]; then | |
echo "- Running PHP Code Sniffer" | |
phpcs --standard=WordPress -q -p $FILES | |
if [ $? != 0 ]; then | |
exit 1 | |
fi | |
fi | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment