/
index.js
61 lines (55 loc) · 1.71 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
/*eslint no-console: "error" */
'use strict';
const arghun = require('../');
const silentSumTreeLog = process.env.SILENT_SUM_TREE === 'true';
const path = process.env.SAMPLE_PATH || './test/testData/testDirectory';
const opt = process.env.SAMPLE_OPT === 'true' ? {
blFiles: ['^index\.', 'meta-inf', 'api.raml', 'apireference.html', 'client.zip', 'apiconsole.html'],
blDir: ['.git', 'apiconsole', 'apinotebooks', 'blog', 'bower_components', 'build', 'error', 'fonts', 'images', 'img', 'internal', 'lunr', 'matrix', 'placeholders', 'scripts', 'styles', 'services/beta', 'services/eu', 'services/us', 'latest$', '/client', '/download', 'vendor']
} : {};
const details = process.env.SAMPLE_PATTERN === 'true' ? [
{
name: "Services",
pattern: "devportal_out/services/"
},
{
name: "Tools",
pattern: "devportal_out/tools/"
},
{
name: "Release Notes",
pattern: "devportal_out/rn/"
},
{
name: "Getting Started",
pattern: "devportal_out/gettingstarted/"
},
{
name: "Overview",
pattern: "devportal_out/overview/"
},
{
name: "Solutions",
pattern: "devportal_out/solutions/"
}
] : [];
async function sample(path) {
try {
console.time('walkDir');
const sumTree = await arghun.walkDir(path, opt);
console.timeEnd('walkDir');
!silentSumTreeLog && console.log('sum', sumTree);
console.time('getTotal');
const total = arghun.getTotal(sumTree);
console.timeEnd('getTotal');
console.log('total', total);
console.time('getCustomDetails');
const patternsSums = arghun.getCustomDetails(sumTree, details);
console.timeEnd('getCustomDetails');
console.log('pattern', patternsSums);
}
catch(err) {
console.log(err);
}
}
sample(path);