1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-30 02:00:10 +02:00

add package.json & prettier to commit flow!

This commit is contained in:
Kushagra Gour
2017-07-03 08:45:32 +05:30
parent 5c25d51235
commit 95585c6274
3 changed files with 259 additions and 267 deletions

23
git-hooks/pre-commit Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/sh
# RUN PRETTIER
jsjsonfiles=$(git diff --staged --name-only | grep ".*\.\(js\|json\)")
echo "$jsjsonfiles" | xargs ./node_modules/.bin/prettier --single-quote --use-tabs --write
echo "$jsjsonfiles" | xargs git add
# Fetch .js or .json filed from staged files
jsfiles=$(git diff --staged --name-only --diff-filter=ACM | grep '\.js$')
[ -z "$jsfiles" ] && exit 0
# ESLINT CHECK
eslintresult=$(./node_modules/.bin/eslint --color $jsfiles)
if [[ $eslintresult != "" ]]; then
echo "$eslintresult"
exit 1 # reject
fi
echo "\033[32m✔ ESlint passed\033[0m"
exit 0