aboutsummaryrefslogtreecommitdiff
path: root/lib/convertLcovToCoveralls.js
diff options
context:
space:
mode:
authorNick Merwin <[email protected]>2017-02-05 12:35:46 -0800
committerNick Merwin <[email protected]>2017-02-05 12:35:46 -0800
commit15750503b69c3143b3020fa5d4fe4fc1d455356e (patch)
tree6119c9160780898ed4504ac3c082407202fef24d /lib/convertLcovToCoveralls.js
parentc81c084fc7280c68e8dc470c31e7291eea183c22 (diff)
downloadnode-coveralls-15750503b69c3143b3020fa5d4fe4fc1d455356e.tar.xz
node-coveralls-15750503b69c3143b3020fa5d4fe4fc1d455356e.zip
branching WIPbranching
Diffstat (limited to 'lib/convertLcovToCoveralls.js')
-rw-r--r--lib/convertLcovToCoveralls.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js
index 68687bd..521e749 100644
--- a/lib/convertLcovToCoveralls.js
+++ b/lib/convertLcovToCoveralls.js
@@ -12,22 +12,34 @@ var detailsToCoverage = function(length, details){
return coverage;
};
+var detailsToBranches = function(details){
+ var branches = [];
+ details.forEach(function(obj){
+ ['line','block','branch','taken'].forEach(function(key){
+ branches.push(obj[key] || 0);
+ });
+ });
+ return branches;
+};
+
var convertLcovFileObject = function(file, filepath){
var rootpath = filepath;
filepath = path.resolve(rootpath, file.file);
var source = fs.readFileSync(filepath, 'utf8');
var lines = source.split("\n");
var coverage = detailsToCoverage(lines.length, file.lines.details);
+ var branches = detailsToBranches(file.branches.details);
return { name : path.relative(rootpath, path.resolve(rootpath, file.file)).split( path.sep ).join( "/" ),
source : source,
- coverage : coverage };
+ coverage : coverage,
+ branches : branches };
};
var cleanFilePath = function(file) {
if (file.indexOf('!') > -1) {
var regex = /^(.*!)(.*)$/g;
var matches = regex.exec(file);
- return matches[matches.length-1];
+ return matches[matches.length-1];
}
return file;