Skip to content

Commit

Permalink
Tweak logic so it only logs on fails
Browse files Browse the repository at this point in the history
  • Loading branch information
rcantin-w committed Sep 23, 2024
1 parent 80f9215 commit 39a938b
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions pa11y/webapp/write-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,23 @@ const promises = urls.map(url =>
Promise.all(promises)
.then(async results => {
if (isPullRequestRun) {
if (results.length > 0) {
const resultsLog = results
.map(result => ({
title: result.documentTitle,
url: result.pageUrl,
errors: result.issues.map(issue => ({
type: issue.type,
message: issue.message,
})),
}))
.flat();
const resultsLog = results
.map(result => {
return result.issues.length > 0
? {
title: result.documentTitle,
url: result.pageUrl,
errors: result.issues.map(issue => ({
type: issue.type,
message: issue.message,
})),
}
: undefined;
})
.filter(f => f)
.flat();

if (resultsLog.length > 0) {
console.error(`!!! ${chalk.redBright('Fix these before merging')}`);
console.log(...resultsLog);

Expand All @@ -96,7 +101,7 @@ Promise.all(promises)
);
if (hasErrors) process.exit(1);
} else {
console.log(chalk.redBright('Report done, no errors found'));
console.log(chalk.greenBright('Report done, no errors found'));
}
} else {
await fs.promises.mkdir('./.dist', { recursive: true });
Expand Down

0 comments on commit 39a938b

Please sign in to comment.