Skip to content

Instantly share code, notes, and snippets.

@danlamanna
Created December 10, 2012 01:47
Show Gist options
  • Save danlamanna/4247925 to your computer and use it in GitHub Desktop.
Save danlamanna/4247925 to your computer and use it in GitHub Desktop.
#!/bin/bash
# skip returns of "No syntax errors..." or "Errors parsing... "
linterrors=$((find wp-content/themes wp-content/mu-plugins -type f -name "*.php" -exec php -l {} \; | egrep -v "^(No|Errors)") 2>&1)
if [ "$linterrors" != "" ]; then
echo "[PRE-COMMIT-ERROR]: Failed PHP Lint Check."
echo "---------------------------------------------"
echo $linterrors
exit 1
fi
exit 0
@danlamanna
Copy link
Author

Needs to be altered to only check altered files per commit, to avoid linting files that haven't changed. See: http://tech.yipit.com/2011/11/16/183772396/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment