Skip to content

Commit 462a0e8

Browse files
fix: report name
1 parent fe880c2 commit 462a0e8

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/report.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,34 @@ const { reportContent, jsonReportContent } = require("../utils/reportContent");
1111
* @param {Object} pages - An object containing information about crawled pages.
1212
*/
1313
function generateReport(baseUrl, pages) {
14-
// Step 1: Sort the crawled pages by occurrence.
15-
const sortedPages = sortPages(pages);
14+
// Step 1: Sort the crawled pages by occurrence.
15+
const sortedPages = sortPages(pages);
1616

17-
// Step 2: Generate an HTML report.
18-
const htmlContent = reportContent(baseUrl, sortedPages);
17+
// Step 2: Generate an HTML report.
18+
const htmlContent = reportContent(baseUrl, sortedPages);
1919

20-
// Step 3: Generate a JSON report.
21-
const jsonContent = jsonReportContent(baseUrl, sortedPages);
20+
// Step 3: Generate a JSON report.
21+
const jsonContent = jsonReportContent(baseUrl, sortedPages);
2222

23-
// Step 4: Create a directory for the report.
24-
fs.mkdirSync(`${__dirname}/awesome-report`, { recursive: true });
23+
const timestamp = Date.now();
24+
const reportDir = `${__dirname}/awesome-report`;
25+
const reportFilePath = `${reportDir}/report-${timestamp}.html`;
26+
const jsonReportFilePath = `${reportDir}/report-${timestamp}.json`;
2527

26-
// Step 5: Write the HTML report to a file.
27-
let reportFilePath = `${__dirname}/awesome-report/report.html`;
28-
fs.writeFileSync(reportFilePath, htmlContent);
28+
// Step 4: Create a directory for the report.
29+
fs.mkdirSync(reportDir, { recursive: true });
2930

30-
// Step 6: Write the JSON report to a file.
31-
let jsonReportFilePath = `${__dirname}/awesome-report/report.json`;
32-
fs.writeFileSync(jsonReportFilePath, JSON.stringify(jsonContent));
31+
// Step 5: Write the HTML report to a file.
32+
fs.writeFileSync(reportFilePath, htmlContent);
3333

34-
// Step 7: Open the HTML report in the default web browser.
35-
console.log("=========================================================");
36-
console.log(`\x1b[22;92mReport generated successfully \x1b[0m`);
37-
console.log(`Report path: `, reportFilePath);
38-
exec(`start ${reportFilePath}`);
34+
// Step 6: Write the JSON report to a file.
35+
fs.writeFileSync(jsonReportFilePath, JSON.stringify(jsonContent));
36+
37+
// Step 7: Open the HTML report in the default web browser.
38+
console.log("=========================================================");
39+
console.log(`\x1b[22;92mReport generated successfully \x1b[0m`);
40+
console.log(`Report path: `, reportFilePath);
41+
exec(`start ${reportFilePath}`);
3942
}
4043

4144
/**

0 commit comments

Comments
 (0)