-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.sh
More file actions
executable file
·30 lines (28 loc) · 895 Bytes
/
check.sh
File metadata and controls
executable file
·30 lines (28 loc) · 895 Bytes
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
#!/bin/bash
RED=`tput setaf 1;`;
GREEN=`tput setaf 2`;
NOCOLOR=`tput sgr0`;
for file in $(git diff --name-only --staged); do
sass_file=$(echo $file | grep '.scss$');
js_file=$(echo $file | grep '.jsx*$');
if [[ ! -z $sass_file ]]; then
lint_output=$(scss-lint $sass_file);
if [[ ! -z $lint_output ]]; then
echo "${file}: ${RED}needs ${RED}formatting!${NOCOLOR}";
echo "${lint_output}";
exit 1;
else
echo "${file}: ${GREEN}passed!${NOCOLOR}";
fi
fi
if [[ ! -z $js_file ]]; then
lint_output=$(./node_modules/.bin/eslint $js_file);
if [[ ! -z $lint_output ]]; then
echo "${file}: ${RED}needs ${RED}formatting!${NOCOLOR}";
echo "${lint_output}";
exit 1;
else
echo "${file}: ${GREEN}passed!${NOCOLOR}";
fi
fi
done