Skip to content

Instantly share code, notes, and snippets.

@atzkey
Last active August 29, 2015 14:13
Show Gist options
  • Save atzkey/5350d87db9381f0ec1e6 to your computer and use it in GitHub Desktop.
Save atzkey/5350d87db9381f0ec1e6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if git rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# Add extensions to check here
extensions='(\.js|\.coffee$)'
files=$(git diff-index --cached --name-only $against --)
for file in $files; do
if [[ $file =~ $extensions ]]; then
errors=$(egrep -n 'debugger|console\.log|(describe|it)\.only|[dw]describe|[dw]it' $file)
if [ "$errors" != "" ]; then
errors="Bad things found in $file:\n$errors"
echo -e "$errors"
exit 1
fi
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment