forked from coding/coding-download-center
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint.sh
executable file
·33 lines (30 loc) · 869 Bytes
/
lint.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
31
32
33
#!/bin/sh
set -e
if [ -z "$1" ]; then
echo "no file"
exit
fi
shell_files=$(echo "$@" | tr ' ' '\n' | { grep ".sh$" || true; })
if [ -n "$shell_files" ]; then
echo "lint shell:"
echo "$shell_files"
echo "$shell_files" | xargs shellcheck
echo "$shell_files" | xargs shfmt -d -i 4 -sr
else
echo "no shell file"
fi
index_file=$(echo "$@" | tr ' ' '\n' | { grep "^index.md$" || true; })
if [ -n "$index_file" ]; then
echo "lint index.md"
echo "check package name sort by a-z"
tail -n +3 index.md > /tmp/index-body.md
cd /tmp
sort index-body.md > index-body-sorted.md
diff index-body.md index-body-sorted.md
packages=$(awk '{print $1}' index-body.md)
for i in $packages; do
expr "$i" : "[a-z0-9\.-]\+$" > /dev/null || (echo "$i: 包名应该全为小写" && exit 250)
done
fi
## lint markdown
# TODO