-
Notifications
You must be signed in to change notification settings - Fork 248
/
index.js
38 lines (34 loc) · 1.16 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const Handlebars = require("handlebars/runtime");
const { formatSummaryForReport, aggregateViolations } = require("./utl");
// eslint-disable-next-line import/no-unassigned-import
require("./error-html.template");
function massageSummaryIntoSomethingUsable(pResults) {
const lSummary = formatSummaryForReport(pResults.summary);
return {
summary: {
...lSummary,
agggregateViolations: aggregateViolations(
lSummary.violations,
lSummary.ruleSetUsed
),
},
};
}
function report(pResults) {
return Handlebars.templates["error-html.template.hbs"](
massageSummaryIntoSomethingUsable(pResults)
);
}
/**
* Returns the results of a cruise in an 'incidence matrix'
*
* @param {import("../../../types/cruise-result").ICruiseResult} pResults - the output of a dependency-cruise adhering to ../../schema/cruise-result.schema.json
* @returns {import("../../../types/dependency-cruiser").IReporterOutput} - output: an html program showing the summary & the violations (if any)
* exitCode: 0
*/
module.exports = function errorHtml(pResults) {
return {
output: report(pResults),
exitCode: 0,
};
};