1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-02-23 14:44:53 +01:00
2018-01-13 12:24:27 +05:30

24 lines
633 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 --single-quote --use-tabs --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/*' --color $jsfiles --quiet)
if [[ $eslintresult != "" ]]; then
echo "$eslintresult"
exit 1 # reject
fi
echo "\033[32m✔ ESlint passed\033[0m"
exit 0