-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·55 lines (44 loc) · 1.42 KB
/
Copy pathpre-commit
File metadata and controls
executable file
·55 lines (44 loc) · 1.42 KB
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
#!/bin/bash
#
language="ruby"
echo -e "\nRunning Lint...\n"
if [ "$language" = "ruby" ]
then
files=$(git diff --cached --name-only --diff-filter=ACM | grep "\.rb$")
if [ "$files" = "" ]; then
exit 0
fi
if ! rubocop ${files}
then
echo -e "\033[31mRubocop validation failed. Your commit contains files that should pass rubocop but do not. Please fix the errors and try again.\033[0m"
exit 1
else
echo -e "\033[32mRubocop validation passed.\033[0m"
fi
elif [ "$language" = "javascript" ]
then
files=$(git diff --cached --name-only --diff-filter=ACM | grep "\.js$")
if [ "$files" = "" ]; then
exit 0
fi
if ! eslint ${files}
then
echo -e "\033[31mESLint validation failed. Your commit contains files that should pass ESLint but do not. Please fix the errors and try again.\033[0m"
exit 1
else
echo -e "\033[32mTSLint validation passed.\033[0m"
fi
elif [ "$language" = "typescript" ]
then
files=$(git diff --cached --name-only --diff-filter=ACM | grep "\.ts$")
if [ "$files" = "" ]; then
exit 0
fi
if ! tslint ${files} --project `pwd`
then
echo -e "\033[31mTSLint validation failed. Your commit contains files that should pass TSLint but do not. Please fix the TSLint errors and try again.\033[0m"
exit 1
else
echo -e "\033[32mTSLint validation passed.\033[0m"
fi
fi