-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (25 loc) · 954 Bytes
/
index.js
File metadata and controls
31 lines (25 loc) · 954 Bytes
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
const ReportService = require("./ReportService")
const configurations = require("./configurations.json")
const pages = require("./pages.json")
const fs = require("fs")
const HtmlService = require("./HtmlService")
var slugify = require("slugify")
var reportService = new ReportService()
var htmlService = new HtmlService()
console.log("Generating report...");
if(!fs.existsSync(".output")){
fs.mkdirSync(".output")
}
fs.readdirSync(".output")
.forEach((file) => {
fs.unlinkSync(`.output/${file}`)
})
reportService.getReports(pages.baseUrl, pages.pages, configurations)
.then((r) => {
r.forEach((report) => {
var page = htmlService.getHtmlFromPageReports(report)
fs.writeFileSync(`.output/${slugify(report.page.name, {lower: true, strict:true})}.html`, page)
})
var homePage = htmlService.getHomeHtmlFromReports(r)
fs.writeFileSync(`.output/index.html`, homePage)
})