File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010# BASE_URL defaults to http://localhost:3000/
1111#
1212# Report shows which page contains each broken link (source page → failed URL).
13- # For the "Broken links by page" section, jq must be installed; otherwise only lychee's default output is shown .
13+ # For the "Broken links by page" section, jq must be installed; otherwise the raw JSON report is kept for manual inspection .
1414
1515set -e
1616
4747# Lychee uses "error_map" (source URL -> list of { url, status: { code } }); some versions use "fail_map".
4848echo " JSON_REPORT: $JSON_REPORT "
4949if [[ -f " $JSON_REPORT " ]]; then
50+ delete_report=1
5051 errors=" "
5152 if command -v jq & > /dev/null; then
5253 errors=$( jq -r ' (.error_map // .fail_map // {}) | to_entries[] | "Page: \(.key)\n Broken:\n\(.value[] | " [\(.status.code)] \(.url)")"' " $JSON_REPORT " 2> /dev/null)
@@ -62,9 +63,12 @@ if [[ -f "$JSON_REPORT" ]]; then
6263 echo " "
6364 echo " === Broken links (report has $report_errors failure(s)); full report: $JSON_REPORT ==="
6465 echo " Install jq to see 'Broken links by page' summary, or: cat $JSON_REPORT | jq '.error_map'"
66+ delete_report=0
6567 fi
6668 fi
67- rm -f " $JSON_REPORT "
69+ if [[ " $delete_report " -eq 1 ]]; then
70+ rm -f " $JSON_REPORT "
71+ fi
6872fi
6973
7074exit " $lychee_exit "
You can’t perform that action at this time.
0 commit comments