forked from kriskowal/q-io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coverage-report.js
44 lines (41 loc) · 1.6 KB
/
coverage-report.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
require("collections/shim");
var Q = require("q");
var FS = require("./fs");
FS.listTree(".coverage_data", function (name, stat) {
return (/^\.coverage_data\/coveragefile/).test(name);
})
.then(function (list) {
return Q.all(list.map(function (file) {
return FS.read(file)
.then(function (content) {
return JSON.parse(content);
})
.then(function (coverage) {
console.log("<table>");
console.log(" <thead>");
console.log(" <tr>");
console.log(" <th>File</th>");
console.log(" <th>Percentage</th>");
console.log(" <th>Missing</th>");
console.log(" </tr>");
console.log(" </thead>");
console.log(" <tbody>");
Object.forEach(coverage.files, function (file, path) {
path = FS.relativeFromDirectory(__dirname, path);
if (/^spec/.test(path))
return;
console.log(" <tr>");
console.log(" <td><code>" + path + "</code></td>");
console.log(" <td>" + (file.stats.percentage * 100).toFixed(0) + "%</td>");
console.log(" <td>" + file.stats.missing + "</td>");
console.log(" </tr>");
});
console.log(" </tbody>");
console.log("</table>");
}, function (error) {
error.message = "Can't parse " + file + " because " + error.message;
throw error;
})
}))
})
.done()