-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mate-scripts] add git-hooks folders for vue projects
- Loading branch information
Showing
3 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
function join_by { local IFS="$1"; shift; echo "$*"; } | ||
|
||
PASS=true | ||
|
||
# ESLint | ||
STAGED_JS_FILES=$(git diff --cached --name-only --diff-filter=ACM ./src | grep ".\(j\|t\)sx\{0,1\}$") | ||
|
||
if [[ "$STAGED_JS_FILES" != "" ]]; then | ||
echo "Linting javascript files" | ||
|
||
npx mate-scripts lint --javascript $(join_by " " ${STAGED_JS_FILES}) | ||
|
||
if [[ "$?" == 0 ]]; then | ||
printf "\033[32mESLint Passed\033[0m\n\n" | ||
else | ||
printf "\033[031mESLint Failed\033[0m\n\n" | ||
PASS=false | ||
fi | ||
fi | ||
|
||
# StyleLint | ||
STAGED_CSS_FILES=$(git diff --cached --name-only --diff-filter=ACM ./src | grep ".s\?css$") | ||
|
||
if [[ "$STAGED_CSS_FILES" != "" ]]; then | ||
echo "Linting CSS files" | ||
|
||
npx mate-scripts lint --styles $(join_by " " ${STAGED_CSS_FILES}) | ||
|
||
if [[ "$?" == 0 ]]; then | ||
printf "\033[32mStyleLint Passed\033[0m\n\n" | ||
else | ||
printf "\033[031mStyleLint Failed\033[0m\n\n" | ||
PASS=false | ||
fi | ||
fi | ||
|
||
if ! ${PASS}; then | ||
printf "Pre-commits check failed. Fix problems above before commit.\n\n" | ||
exit 1 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
function join_by { local IFS="$1"; shift; echo "$*"; } | ||
|
||
PASS=true | ||
|
||
# ESLint | ||
STAGED_JS_FILES=$(git diff --cached --name-only --diff-filter=ACM ./src | grep ".\(j\|t\)sx\{0,1\}$") | ||
|
||
if [[ "$STAGED_JS_FILES" != "" ]]; then | ||
echo "Linting javascript files" | ||
|
||
npx mate-scripts lint --javascript $(join_by " " ${STAGED_JS_FILES}) | ||
|
||
if [[ "$?" == 0 ]]; then | ||
printf "\033[32mESLint Passed\033[0m\n\n" | ||
else | ||
printf "\033[031mESLint Failed\033[0m\n\n" | ||
PASS=false | ||
fi | ||
fi | ||
|
||
# StyleLint | ||
STAGED_CSS_FILES=$(git diff --cached --name-only --diff-filter=ACM ./src | grep ".s\?css$") | ||
|
||
if [[ "$STAGED_CSS_FILES" != "" ]]; then | ||
echo "Linting CSS files" | ||
|
||
npx mate-scripts lint --styles $(join_by " " ${STAGED_CSS_FILES}) | ||
|
||
if [[ "$?" == 0 ]]; then | ||
printf "\033[32mStyleLint Passed\033[0m\n\n" | ||
else | ||
printf "\033[031mStyleLint Failed\033[0m\n\n" | ||
PASS=false | ||
fi | ||
fi | ||
|
||
if ! ${PASS}; then | ||
printf "Pre-commits check failed. Fix problems above before commit.\n\n" | ||
exit 1 | ||
fi |
This file contains 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