-
Notifications
You must be signed in to change notification settings - Fork 248
/
index.js
36 lines (32 loc) · 981 Bytes
/
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
const Handlebars = require("handlebars/runtime");
const dependencyToIncidenceTransformer = require("../utl/dependency-to-incidence-transformer");
// eslint-disable-next-line import/no-unassigned-import
require("./html.template");
function addShowTitle(pDependencyEntry) {
return {
...pDependencyEntry,
incidences: pDependencyEntry.incidences.map((pIncidence) => ({
...pIncidence,
hasRelation: pIncidence.incidence !== "false",
})),
};
}
function report(pResults) {
return Handlebars.templates["html.template.hbs"]({
modules: dependencyToIncidenceTransformer(pResults.modules).map(
addShowTitle
),
});
}
/**
* Returns the results of a cruise in an 'incidence matrix'
*
* @param {import("../../../types/cruise-result").ICruiseResult} pResults
* @returns {import("../../../types/dependency-cruiser").IReporterOutput}
*/
module.exports = function html(pResults) {
return {
output: report(pResults),
exitCode: 0,
};
};