-
Notifications
You must be signed in to change notification settings - Fork 1
/
ccm.js
42 lines (34 loc) · 1.12 KB
/
ccm.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
var calculator = require('./lib/calculator');
var results = require('./lib/results');
var formatter = require('./lib/formatter');
var fileCalculator = require('./lib/filecalculator');
var fileFilter = require('./lib/fileFilter');
var fs = require('fs');
var util = require('util');
var glob = require('glob');
var minimatch = require('minimatch');
function run(options) {
var filter = fileFilter.create(options.exclude);
var topResult = results.createResult(parseInt(options.results));
var ccmCalculator = {
calculate: calculator.calculate,
}
var calc = fileCalculator.create(fs, ccmCalculator, topResult, function(file) {
return !filter(file);
});
glob(options.files, function(err, files) {
var res = calc.calculateFor(files);
formatter.formatResult(res.results).forEach(function(res) {
console.log(res);
});
if(res.errors && res.errors.length > 0) {
console.log('\nFailed to parse the following files:');
res.errors.forEach(function(err) {
console.log(err.file + ' (' + err.line + ',' + err.col + '): ' + err.message);
});
}
});
}
module.exports = {
run: run
};