2017-07-03 08:45:32 +05:30
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# RUN PRETTIER
|
2018-01-13 12:24:27 +05:30
|
|
|
filesToPrettify=$(git diff --staged --name-only | grep ".*\.\(js\|json\|css\|md\)")
|
2018-04-14 23:05:35 +05:30
|
|
|
echo "$fileToPrettify" | xargs ./node_modules/.bin/prettier --config ./prettierrc --write
|
2018-01-13 12:24:27 +05:30
|
|
|
echo "$fileToPrettify" | xargs git add
|
2017-07-03 08:45:32 +05:30
|
|
|
|
|
|
|
# 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
|
2018-01-14 00:27:22 +05:30
|
|
|
eslintresult=$(./node_modules/.bin/eslint --ignore-pattern '/src/lib/*' --fix --color $jsfiles --quiet)
|
2017-07-03 08:45:32 +05:30
|
|
|
|
|
|
|
if [[ $eslintresult != "" ]]; then
|
|
|
|
echo "$eslintresult"
|
|
|
|
exit 1 # reject
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "\033[32m✔ ESlint passed\033[0m"
|
|
|
|
|
|
|
|
exit 0
|