forked from thi-ng/umbrella
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats
executable file
·33 lines (27 loc) · 799 Bytes
/
stats
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
# usage: stats packages stats.csv (default)
# usage: stats examples stats-ex.csv
if [ $# -gt 0 ]; then
modules="$1/*"
else
modules="packages/*"
fi
if [ $# -gt 1 ]; then
out="$2"
else
out=assets/stats.csv
fi
echo "package,files,comments,sloc" > $out
for m in $modules; do
if [ -d "$m" ]; then
skip=$(grep -e '"skip": true' "$m/package.json")
if [ -e "$m/.skip" ] || [ -n "$skip" ]; then
echo "\tskipping $m"
else
echo "$m $skip"
echo "$m,$(cloc "$m"/src --csv | grep "TypeScript" | cut -d ',' -f1 -f4-5)" >> $out
fi
fi
done
echo "---"
awk -F ',' '{ files+=$2; comments+=$3; sloc+=$4 } END { print "files:", files, "\tcode:", sloc, "\tcomments:", comments, "\ttotal:", sloc + comments }' $out