Skip to content

Commit 5fbb012

Browse files
committed
Avoid passing whole report to failBuild utility
Removes generatePostrunMessage function
1 parent 0ccfb12 commit 5fbb012

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

src/index.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,19 @@ module.exports = {
2222
htmlFilePaths,
2323
pa11yOpts,
2424
})
25-
const log = issueCount === 0 ? console.log : failWithIssues ? build.failBuild : console.warn
26-
log(generatePostrunMessage(issueCount, report))
25+
const reportSummary =
26+
`${issueCount === 0 ? 'No' : issueCount} accessibility issues found!` +
27+
(issueCount > 0 ? ' Check the logs for more information.' : '')
28+
29+
console.log(report)
30+
31+
if (failWithIssues) {
32+
build.failBuild(reportSummary)
33+
} else {
34+
console.warn(pico.magenta(reportSummary))
35+
}
2736
} catch (err) {
2837
build.failBuild(err.message)
2938
}
3039
},
3140
}
32-
33-
/**
34-
* Generates the message sent to the build log after a11y checks have been peformed.
35-
* @param {number} issueCount
36-
* @param {string} report
37-
*/
38-
function generatePostrunMessage(issueCount, report) {
39-
// Only print a line between the report and the summary
40-
// if the report has any contents.
41-
const spacer = report.length > 0 ? '\n' : ''
42-
const humanReadableCount = issueCount === 0 ? 'No' : issueCount
43-
const summary = `${humanReadableCount} accessibility violations found! ${
44-
issueCount > 0 ? 'Check the logs above for more information.' : ''
45-
}`
46-
return report + spacer + pico.magenta(summary)
47-
}

0 commit comments

Comments
 (0)