-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
executable file
·77 lines (71 loc) · 2.4 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env node
/* eslint-disable no-console */
const fs = require("fs");
const path = require("path");
const cssAnalyzer = require("./src/css/compat-analyzer");
const jsAnalyzer = require("./src/js/compat-analyzer");
const htmlAnalyzer = require("./src/html/compat-analyzer");
const reportHelpers = require("./lib/report");
// Exports API
exports.htmlStringAnalyzer = function htmlStringAnalyzer (string, browserScope, cbReport, options){
htmlAnalyzer.analyzeString(string, browserScope, 0, "HTMLString", (e, d) => {
if (e) {
console.error(e);
return false;
}
const report = d;
cbReport(report);
}, options);
};
exports.cssStringAnalyzer = function cssStringAnalyzer (string, browserScope, cbReport, options){
cssAnalyzer.analyzeString(string, browserScope, 0, "CSSString", (e, d) => {
if (e) {
console.error(e);
return false;
}
const report = d;
cbReport(report);
}, options);
};
exports.jsStringAnalyzer = function jsStringAnalyzer (string, browserScope, cbReport, options){
jsAnalyzer.analyzeString(string, browserScope, 0, "JSString", (e, d) => {
if (e) {
console.error(e);
return false;
}
const report = d;
cbReport(report);
}, options);
};
exports.htmlFileAnalyzer = function htmlFileAnalyzer (filePath, browserScope, cbReport, options){
htmlAnalyzer.analyzeFile(filePath, browserScope, (e, d) => {
if (e) {
console.error(e);
return false;
}
const report = d;
cbReport(report);
}, options);
};
exports.cssFileAnalyzer = function cssFileAnalyzer (filePath, browserScope, cbReport, options){
const content = fs.readFileSync(filePath,"utf-8");
cssAnalyzer.analyzeString(content, browserScope, 0, path.basename(filePath), (e, d) => {
if (e) {
console.error(e);
return false;
}
const report = d;
cbReport(report);
}, options);
};
exports.jsFileAnalyzer = function jsFileAnalyzer (filePath, browserScope, cbReport, options){
const content = fs.readFileSync(filePath,"utf-8");
jsAnalyzer.analyzeString(content, browserScope, 0, path.basename(filePath), (e, d) => {
if (e) {
console.error(e);
return false;
}
const report = d;
cbReport(report);
}, options);
};