Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80668 views
1
var path = require('path');
2
var colors = require('../contrib/colors')
3
4
module.exports.MAX_FILENAME_LENGTH = 60;
5
module.exports.name = "cli";
6
module.exports.format = function(coverageData) {
7
var stats = coverageData.stats();
8
var filename = path.relative(process.cwd(), coverageData.filename);
9
10
if (filename.length > module.exports.MAX_FILENAME_LENGTH) {
11
filename = "…" + filename.substr(filename.length - module.exports.MAX_FILENAME_LENGTH + 2);
12
}
13
14
var blockPercentage = Math.floor(stats.blocks.percentage * 100);
15
var linePercentage = Math.floor(stats.percentage * 100);
16
17
var blockColor = "____";
18
if (blockPercentage >= 75) {
19
blockColor = "green";
20
}
21
else if (blockPercentage >= 50) {
22
blockColor = "yellow";
23
}
24
else {
25
blockColor = "red";
26
}
27
28
var lineColor = "";
29
if (linePercentage >= 75) {
30
lineColor = "green";
31
}
32
else if (linePercentage >= 50) {
33
lineColor = "yellow";
34
}
35
else {
36
lineColor = "red";
37
}
38
39
return [
40
filename,
41
(Math.floor(stats.percentage * 100) + "%")[lineColor],
42
stats.missing,
43
stats.total,
44
(Math.floor(stats.blocks.percentage * 100) + "%")[blockColor],
45
stats.blocks.missing,
46
stats.blocks.total];
47
}
48