Skip to content

Commit c5c2347

Browse files
authored
Prevent overly verbose broken link logging from linkinator (#17381)
* Prevent overly verbose broken link logging from linkinator * Reduce unnecessary second 'map' call * Be VERY sure we aren't logging the failureDetails in case the linkinator implementation changes * Really smoosh that '.map' call down to size
1 parent dc21051 commit c5c2347

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

script/check-english-links.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ async function main () {
6767

6868
// Update CLI output and append to logfile after each checked link.
6969
checker.on('link', result => {
70+
// We don't need to dump all of the HTTP and HTML details
71+
delete result.failureDetails
72+
7073
fs.appendFileSync(logFile, JSON.stringify(result) + '\n')
7174
})
7275

@@ -113,11 +116,7 @@ function displayBrokenLinks (brokenLinks) {
113116
const allStatusCodes = uniq(brokenLinks
114117
// Coerce undefined status codes into `Invalid` strings so we can display them.
115118
// Without this, undefined codes get JSON.stringified as `0`, which is not useful output.
116-
.map(link => {
117-
if (!link.status) link.status = 'Invalid'
118-
return link
119-
})
120-
.map(link => link.status)
119+
.map(link => link.status || 'Invalid')
121120
)
122121

123122
allStatusCodes.forEach(statusCode => {
@@ -126,6 +125,9 @@ function displayBrokenLinks (brokenLinks) {
126125
console.log(`## Status ${statusCode}: Found ${brokenLinksForStatus.length} broken links`)
127126
console.log('```')
128127
brokenLinksForStatus.forEach(brokenLinkObj => {
128+
// We don't need to dump all of the HTTP and HTML details
129+
delete brokenLinkObj.failureDetails
130+
129131
console.log(JSON.stringify(brokenLinkObj, null, 2))
130132
})
131133
console.log('```')

0 commit comments

Comments
 (0)