-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (38 loc) · 1.16 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
/**
* @file 入口
* @author mengke01([email protected])
*/
const parser = (() => {
if (process.platform === 'win32') {
return require('./parser-x64-win32.node');
}
else if (process.platform === 'darwin' && process.arch === 'x64') {
return require('./parser-x64-darwin.node');
}
else if (process.platform === 'darwin' && (process.arch === 'arm64')) {
return require('./parser-aarch64-darwin.node');
}
return require('./parser-mock.js');
})();
exports.parseScript = filePath => {
const result = parser.parseScript(filePath);
return JSON.parse(result);
};
exports.parseScriptFiles = filePaths => {
if (!Array.isArray(filePaths)) {
throw new Error('file paths should be array!');
}
const result = parser.parseScriptFiles(filePaths);
return JSON.parse(result);
};
exports.parseCss = filePath => {
const result = parser.parseCss(filePath);
return JSON.parse(result);
};
exports.parseCssFiles = filePaths => {
if (!Array.isArray(filePaths)) {
throw new Error('file paths should be array!');
}
const result = parser.parseCssFiles(filePaths);
return JSON.parse(result);
};