1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-01-17 12:28:14 +01:00
2018-04-14 23:05:35 +05:30

24 lines
635 B
Bash
Executable File

#!/bin/sh
# RUN PRETTIER
filesToPrettify=$(git diff --staged --name-only | grep ".*\.\(js\|json\|css\|md\)")
echo "$fileToPrettify" | xargs ./node_modules/.bin/prettier --config ./prettierrc --write
echo "$fileToPrettify" | 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 --ignore-pattern '/src/lib/*' --fix --color $jsfiles --quiet)
if [[ $eslintresult != "" ]]; then
echo "$eslintresult"
exit 1 # reject
fi
echo "\033[32m✔ ESlint passed\033[0m"
exit 0