-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalyze.js
40 lines (32 loc) · 1.22 KB
/
analyze.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
39
40
const path = require("path");
const fs = require("fs");
const { exec } = require("child_process");
const analyzeLuaFiles = require("./index.js");
const parseReportToHTML = require("./test.js"); // Adjust if the function is in another file
function generateHTMLReport(data) {
const reportData = JSON.parse(data);
let htmlContent = `<html><head><title>Analysis Report</title></head><body><h1>Analysis Report</h1>`;
reportData.forEach(item => {
htmlContent += `<div><h2>${item.name}</h2><p>${item.description}</p></div>`;
});
htmlContent += `</body></html>`;
return htmlContent;
}
if (require.main === module) {
const args = process.argv.slice(2);
const filePath = args[0];
if (!filePath) {
console.error("Usage: npm run run-analysis <file.lua>");
process.exit(1);
}
console.log(`Starting analysis for file: ${filePath}`);
analyzeLuaFiles(filePath)
.then(() => {
console.log('Analyzing Lua files completed. Generating HTML report from report.json');
parseReportToHTML('report.json');
})
.catch((error) => {
console.error("Error:", error);
});
}
module.exports = { analyzeLuaFiles, generateHTMLReport };