-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge.js
60 lines (49 loc) · 1.73 KB
/
merge.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
// import fs from 'fs';
// import path from 'path';
import MonocartReporter from 'monocart-reporter';
const main = async () => {
const reportDataList = [
// json file path
'docs/shard1/custom.zip',
'docs/shard2/custom.zip',
'docs/shard3/custom.zip'
// or JSON data
// JSON.parse(fs.readFileSync(path.resolve('docs/shard3/index.json')))
];
// console.log(reportDataList);
await MonocartReporter.merge(reportDataList, {
// logging: 'debug',
name: 'My Merged Report',
outputFile: 'docs/merged/index.html',
durationStrategy: 'exclude-idle',
// attachmentPath: (currentPath, extras) => {
// const prevPath = path.resolve(extras.cwd, extras.outputDir, currentPath);
// const newDir = path.resolve('docs/merged');
// // console.log(prevPath, newDir);
// const newPath = path.relative(newDir, prevPath);
// // console.log(newPath);
// return newPath;
// },
onData: (reportData, dataList) => {
dataList.forEach((data) => {
console.log('data item name =========== ', data.name);
});
},
onEnd: async (reportData, capacity) => {
}
});
// test remove all json file
// const list = fs.readdirSync(path.resolve('docs'), {
// withFileTypes: true
// });
// for (const item of list) {
// if (item.isDirectory()) {
// const jsonPath = path.resolve('docs', item.name, 'index.json');
// if (fs.existsSync(jsonPath)) {
// console.log(`remove ${jsonPath}`);
// fs.rmSync(jsonPath);
// }
// }
// }
};
main();