-
Notifications
You must be signed in to change notification settings - Fork 2
/
js-complexity-viz.js
83 lines (73 loc) · 1.82 KB
/
js-complexity-viz.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
78
79
80
81
82
83
#!/usr/bin/env node
var complexity = require('./src/js-complexity');
/*
var metrics = require('./src/metrics');
var history = require('./src/history').run;
if (module.parent) {
module.exports = {
complexity: complexity,
metrics: metrics
};
} else {
var args = require('./src/arguments').run();
console.assert(args, 'could not find args structure');
var logger = require('optional-color-logger');
logger.init(args);
console.assert(args.path, 'empty path');
if (!Array.isArray(args.path)) {
args.path = [args.path];
}
if (!Array.isArray(args.skip)) {
args.skip = [args.skip];
}
if (args.history > 0) {
history({
filename: args.path[0],
report: args.report,
commits: args.history
});
} else {
complexity.run({
report: args.report,
path: args.path,
colors: args.colors,
limit: args.limit,
sort: args.sort,
minimal: args.minimal,
skip: args.skip
});
}
*/
if (module.parent) {
module.exports = complexity;
} else {
var updateNotifier = require('update-notifier');
var notifier = updateNotifier();
if (notifier.update) {
notifier.notify();
}
var fs = require("fs");
var path = require("path");
var check = require('check-types');
var arguments = require('./src/arguments').run();
console.assert(arguments, 'could not find args structure');
var logger = require('optional-color-logger');
logger.init(arguments);
console.assert(arguments.path, 'empty path');
if (!Array.isArray(arguments.path)) {
arguments.path = [arguments.path];
}
if (!Array.isArray(arguments.skip)) {
arguments.skip = [arguments.skip];
}
log.debug('looking for js files in folders', arguments.path);
complexity.run({
report: arguments.report,
path: arguments.path,
colors: arguments.colors,
limit: arguments.limit,
sort: arguments.sort,
minimal: arguments.minimal,
skip: arguments.skip
});
}