Skip to content

Instantly share code, notes, and snippets.

@kovshenin
Created November 5, 2021 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kovshenin/d6fd8f3255eb36fca006bbda22ff4c5e to your computer and use it in GitHub Desktop.
Save kovshenin/d6fd8f3255eb36fca006bbda22ff4c5e to your computer and use it in GitHub Desktop.
Pre-deploy hook for Sail CLI
#!/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