summaryrefslogtreecommitdiff
path: root/checklinks.sh
blob: dd9262b7f2454a0beead4aaf59435df9cc549a2b (plain)
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
#!/bin/bash

echo "Checking links in documentation..."

# List of files in docs dir
docs=$(find . -path './docs/*.md')
# List of files in project root (README, etc)
extras=$(find . -maxdepth 1 -name '*.md')
# Combined list of files to check
files=("${docs[@]}" "${extras[@]}")

let "fails=0"
let "count=0"

for file in ${files[@]}; do
    let "count++"
    markdown-link-check -q "$file"
    if [ $? -ne 0 ]; then
        let "fails++"
    fi
done

echo -e "\n\033[0;33m$count files checked."

if [ $fails -gt 0 ]; then
    echo -e "\033[0;31mERROR: $fails files with dead links found!"
    exit 1
else
    echo -e "\033[0;32mCongratulations! No dead links found."
    exit 0
fi