forked from Epitech/coding-style-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coding-style.sh
executable file
·30 lines (26 loc) · 1.23 KB
/
coding-style.sh
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
function cat_readme() {
echo ""
echo "Usage: ./coding-style.sh DELIVERY_DIR REPORTS_DIR"
echo " DELIVERY_DIR Should be the directory where your project files are"
echo " REPORTS_DIR Should be the directory where we output the reports"
echo " Take note that existing reports will be overriden"
echo ""
}
if [ $# == 1 ] && [ $1 == "--help" ]; then
cat_readme
elif [ $# = 2 ];
then
DELIVERY_DIR=$(readlink -f "$1")
REPORTS_DIR=$(readlink -f "$2")
EXPORT_FILE="$REPORTS_DIR"/coding-style-reports.log
### delete existing report file
rm -f $EXPORT_FILE
### Pull new version of docker image and clean olds
sudo docker pull ghcr.io/epitech/coding-style-checker:latest && sudo docker image prune -f
### generate reports
sudo docker run --rm -i -v "$DELIVERY_DIR":"/mnt/delivery" -v "$REPORTS_DIR":"/mnt/reports" ghcr.io/epitech/coding-style-checker:latest "/mnt/delivery" "/mnt/reports"
[[ -f $EXPORT_FILE ]] && echo "$(wc -l < $EXPORT_FILE) coding style error(s) reported in $EXPORT_FILE, $(grep -c ": MAJOR:" $EXPORT_FILE) major, $(grep -c ": MINOR:" $EXPORT_FILE) minor, $(grep -c ": INFO:" $EXPORT_FILE) info"
else
cat_readme
fi