Skip to content

Commit d0df700

Browse files
jeffabaileyCopilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent f29606c commit d0df700

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

scripts/lychee-book.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
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

1515
set -e
1616

@@ -47,6 +47,7 @@ set -e
4747
# Lychee uses "error_map" (source URL -> list of { url, status: { code } }); some versions use "fail_map".
4848
echo "JSON_REPORT: $JSON_REPORT"
4949
if [[ -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
6872
fi
6973

7074
exit "$lychee_exit"

0 commit comments

Comments
 (0)