-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathblc-good-enough.sh
30 lines (25 loc) · 1.05 KB
/
blc-good-enough.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
#!/bin/bash
# usage, e.g. if you find 10 an acceptable number of broken links
# bash blc-good-enough 10
# get the maximum allowed number of broken links
broken_max="$1"
# run the link checker
echo "travis_fold:start:blc"
echo "Checking for any broken links..."
docker run -v $PWD:/docs peterevans/liche:1.1.1 -v -t 60 -c 16 -d /docs -r /docs 2> stdout.txt
echo "travis_fold:end:blc"
# get the actual number of broken links
broken=$(grep ERROR stdout.txt | wc -l)
echo
echo "-------------------------------------------------------------------------------------------"
echo "-- BROKEN LINK CHECKER: SUMMARY --"
echo "-------------------------------------------------------------------------------------------"
echo
if [ "$broken" -gt "$broken_max" ]; then
echo "Number of broken links (${broken}) exceeds maximum allowed number (${broken_max})." >&2
cat stdout.txt
exit 1
else
echo "Number of broken links (${broken}) less than or equal to maximum allowed number (${broken_max})."
exit 0
fi