Created
July 7, 2015 09:27
-
-
Save nikolaymatrosov/e78672a17ab45a58b882 to your computer and use it in GitHub Desktop.
Pre-commit hook (check for forgotten `only`, run client tests only on client code changes)
This file contains 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/sh | |
SRC=$(git rev-parse --show-toplevel)/src/client | |
#========================================================== | |
# Check if I forgot to remove 'only' keyword from tests. | |
# To make sure that before commit run all tests | |
only=`grep -c -h -r --include "*.spec.js" -E "(describe|it)\.only" $SRC/src | awk -F ':' '{x +=$0}; END {print x}'` | |
if (( $((only)) > 0 )) | |
then | |
echo 'Remove ONLY from tests.' | |
# Output list of found only entries | |
grep -r -n --include "*.spec.js" -E "(describe|it)\.only" $SRC/src | |
exit 1 | |
fi | |
#========================================================== | |
ch=`git diff --cached --name-only --diff-filter=ACM | grep 'src/client' -c` | |
if (( $((ch)) > 0 )) | |
then | |
echo "client" | |
gulp pre-commit --stdio inherit --cwd $SRC | |
else | |
echo "Server only. No pre-commit hook" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment