Last active
September 7, 2016 05:23
-
-
Save unRob/f74e6f0bd224d30033370854b515ddef to your computer and use it in GitHub Desktop.
pre-commit do something on patterns
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 | |
# mkdir -p bin/hooks | |
# curl -v -L https://gist.github.com/unRob/f74e6f0bd224d30033370854b515ddef/raw/install-hooks.sh > bin/install-hooks | |
# chmod +x bin/install-hooks | |
# curl -v -L https://gist.github.com/unRob/f74e6f0bd224d30033370854b515ddef/raw/pre-commit.sh > bin/hooks/pre-commit | |
# chmod +x bin/hooks | |
# bin/install-hooks | |
# echo "Remember to delete unused hooks (or to suggest a good way to do so automatically)" | |
# exit on error | |
set -e | |
APP_ROOT=`git rev-parse --show-toplevel` | |
HOOKS=${APP_ROOT}/bin/hooks/* | |
for file in $HOOKS; do | |
ln -sfv "$file" "$APP_ROOT/.git/hooks/" | |
done |
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 | |
# curl -v -L https://gist.github.com/unRob/f74e6f0bd224d30033370854b515ddef/raw/pre-commit.sh > .git/hooks/pre-commit | |
# echo "Let's look at what we've just downloaded off a stranger on the internets!" && cat .git/hooks/pre-commit | |
# chmod +x .git/hooks/pre-commit | |
# exit on error | |
set -e | |
staged() { | |
[ `git diff --name-only --cached | grep -E "$1"` ] | |
} | |
# Use regular expressions to query staged files | |
if ( staged "(models|api)/.+\.js$" ) || ( staged ".ejs$" ) || ( staged "config/spec.yaml" ) | |
then | |
echo "Generating documentation..." | |
npm run docs | |
git add docs/ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment