-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-commit
115 lines (101 loc) · 5.38 KB
/
pre-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".*\.\(ts\|tsx\)")
ESLINT="$(git rev-parse --show-toplevel)/node_modules/.bin/eslint"
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
printf "\nSebelum dicommit, kode JS nya divalidasi dulu ya gan. Untuk info lebih jelas boleh tanya [email protected]\n"
printf "\nValidasi dimulai\n"
# Cek eslint
if [[ ! -x "$ESLINT" ]]; then
printf "\t\033[41mBelum install ESlint, install dengan perintah:\033[0m npm i --save-dev eslint\n\n"
exit 1
fi
for FILE in $STAGED_FILES
do
"$ESLINT" "$FILE"
if [[ "$?" == 0 ]]; then
printf "\t$FILE \033[32mLOLOS\033[0m\n"
else
printf "\t$FILE \033[31mGAGAL\033[0m\n"
PASS=false
fi
done
printf "\nValidasi kode selesai\n\n"
if ! $PASS; then
# printf "\033[41mCOMMIT FAILED:\033[0m Your commit contains files that should pass ESLint but do not. Please fix the ESLint errors and try again.\n\n"
printf "\033[0;31m"
cat << "EOF"
.....,,,,,,,,,***.........,,/////(/////,.........***,,,,,,,.....
......,**********///,,,,,,****##########(***,,,,,.///*****,,,,,.
......,,*/////////((((**** .*//***/((///******,.
...., ,(((###### ...,,,,,.,,,,,,,,,. .###(((////**........
....,. ,,,,,. *%%%. .,,,,,,,,,,,,,. .,,,,,,, ,###(((/,.............
......,,, ,,,,,,,,. ,,,,,, *&&&&%#&&,...,,,,,, .,,, /##(**,,,,,,,,,...,,.
.,,,...,,* ,,,,,,,,,,,,,,*/&&&&(, .,,,,,,,&&&& .,,,. ///////*,,..,,**,,,
,,,,***,,,*//. .,,,,,,,,,,,,** ##*## ,,,,,,,,.,(&&&&&%.,,. ..,,,,. **,,
,,,***///*,*/(( ,,,,,,,,,,. .,,,,,,.,,,,,,,, /(/ .%&,,,,,,,,,,,,,,,,, /**,
,,***///((##// .,,,,,,,,..,,,,,,,,,,,,..,,,..,. .# .,,,,,,,,,,,,,,,, *//%@&
,****//(%@##%/ .,,,,,,,,,,,, ,,,,,,,,,,...,,,,,,,,,,,,,,,,,,,,,,. .(#((///**
***///..,/#%% .,,,,,,,,,,,,, ,,,,,,,,.....,,,,, ...,,,,,,,,, #&&%%%#((/**((/
.,*///(/,./%&*..,,,,,,,,,,,.,,,,,,,,,,,,,,,,.,,.,,,,,,,,,,,,. ,(.(%(.*(##(/*,
....*(##%%& .,..##,,,,,,,,,,,,,..,,,,.,,,,,,,,,,,,,,,,,,,.*&.%&%%#/******,
......,,@@#% .,,,,,,.,/. ..,#%/ .,,,,,,,,,,,,,,*. &%((///******,
......,,,(//( .,,,..%%&&&&&&&&&&% %&&&&&&&&&&.*,,, .,/(((/*,,, .*
.. ....,/#%&&,.&&&&&&&&&&(&&&&&&%* ,#&&&&&&&&&&&&&&&&&,. ##((////******
****,,,,**//* ..%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&((&&&&&&&&& ##((/////////(
///*.,*/*..,, ,&&&&&&&&&&&&&&&%&&&&&&&&&&&&&&%&&&&&&&&&&&&&&*.*(%&&&&%/.(####(
(((###%%%%&&&. %/&&&&%*&&&&&&&&&&&&&&(&&&&&&&&&&/&&&&&&&.&&&&(% &&&&%#,,&&&/*(
(((###%%%%&**# &&%&&&&&% %&&&*%&&&&&% &&&&&&&%&&&&&&%&&&&&&,.&( ,&&&&%%%%##,..(
(((####%#,*#&, && *%%%&&&&&&&&&&&&%( %&&&&&&&&&%&&&&& (&, (&&&%%%###(((//
(((((/,*.//(( &% /#%%%%%%%%(. (%%&&&&&&&&%#, %& /*,,..,,*/////*
,,,* ***//(( @@@@@@(@@@@%@@@%@@@@@@*. ,&& /*,....
,,,,,*****//( &( @@@@@* /, .(. .#(. @@@@@@* % ,*,,...
..... ...,,/# .&( @@@& *@@@@& &&. &*..
./(##%% . , ..,,,,,.. /#. (&& &%%###(@@*
.*////((##%% .&& ,,*///////////*,,, , & /%%###((((///,.
****//@@@(##% .&& .& ,//////////////////, /@@ %&&. %%%##(((////*****
,,****//((##% .&&% @@ ,.//////////////////* @@@ %& *(##(((////****,,
,,,***///((#( &&&% @@@@@*##,/*.*//////.(* @@@@@ *&&&& **,,,((////****,,,
,,,,***//*,,* %&&& /@@@@@@&@@@& %@@.%@@@@@@@, /&&&&&/ ,@*,.. ./*****,,,,
.,,,,**....,,* %&&&&&% (&@@@@@@@@@@@@@@@@, ,&&&&&&%% /*,... .***,,,,.
..,,. ...,,* #%&&&&&&. .(&&&&&&&&%#. #/,... .,,,..
.. ...,,*. .%%&&&&&&&&&&&&&%%%%&&&&&&&&&&&&&&%/ .##((/.. ...
...,((# %%&&&&&&&&&&&&&&&&&&&&&&&&&&%( ###(((///. *%
,*//(((. (%%%%%%&&&&&&&&&&&&&&&%%(. ,/#(((////****
.,,***//(@%(. *(##%%%%%%%%#/. ***,,*////*****,,,.
.,,,,,,***///(*****,. .#@**,,,,...******,,,,,,,.
__ __ _ _ _
| \/ | (_) | | |
| \ / | __ _ ___ _| |__ ___ _ __ _ __ ___ _ __ __ _ __ _ _ __ | |
| |\/| |/ _` / __| | '_ \ / _ \ '__| '__/ _ \| '__| / _` |/ _` | '_ \| |
| | | | (_| \__ \ | | | | | __/ | | | | (_) | | | (_| | (_| | | | |_|
|_| |_|\__,_|___/_|_| |_| \___|_| |_| \___/|_| \__, |\__,_|_| |_(_)
__/ |
|___/
EOF
printf "\033[0m"
exit 1
else
printf "\033[0;32m"
cat << "EOF"
┈┈┈┈┈┈▕▔╲
┈┈┈┈┈┈┈▏▕
┈┈┈┈┈┈┈▏▕▂▂▂
▂▂▂▂▂▂╱┈▕▂▂▂▏
▉▉▉▉▉┈┈┈▕▂▂▂▏
▉▉▉▉▉┈┈┈▕▂▂▂▏
▔▔▔▔▔▔╲▂▕▂▂▂I
__ __ _ _ _
| \/ | | | | | | |
| \ / | __ _ _ __ | |_ __ _| |__ __ _ __ _ _ __ | |
| |\/| |/ _` | '_ \| __/ _` | '_ \ / _` |/ _` | '_ \| |
| | | | (_| | | | | || (_| | |_) | | (_| | (_| | | | |_|
|_| |_|\__,_|_| |_|\__\__,_|_.__/ \__, |\__,_|_| |_(_)
__/ |
|___/
EOF
printf "\033[0m"
fi
exit $?