Skip to content

Commit

Permalink
implemented code to parse concatenated file paths (fixes #143)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Davis committed Nov 11, 2016
1 parent acc1fd8 commit f9c3697
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 11 additions & 0 deletions lib/convertLcovToCoveralls.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ var convertLcovFileObject = function(file, filepath){
coverage : coverage };
};

var cleanFilePath = function(file) {
if (file.indexOf('!') > -1) {
var regex = /^(.*!)(.*)$/g;
var matches = regex.exec(file);
return matches[matches.length-1];
}

return file;
};

var convertLcovToCoveralls = function(input, options, cb){
var filepath = options.filepath || '';
logger.debug("in: ", filepath);
Expand Down Expand Up @@ -61,6 +71,7 @@ var convertLcovToCoveralls = function(input, options, cb){
postJson.service_pull_request = options.service_pull_request;
}
parsed.forEach(function(file){
file.file = cleanFilePath(file.file);
var currentFilePath = path.resolve(filepath, file.file);
if (fs.existsSync(currentFilePath)) {
postJson.source_files.push(convertLcovFileObject(file, filepath));
Expand Down
5 changes: 2 additions & 3 deletions test/convertLcovToCoveralls.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,16 @@ describe("convertLcovToCoveralls", function(){
};

var originalExistsSync = fs.existsSync;
fs.existsSync = function () { return false; };
fs.existsSync = function () { return true; };

convertLcovToCoveralls(input, {filepath: libpath}, function(err, output){
fs.readFileSync = originalReadFileSync;
fs.existsSync = originalExistsSync;

should.not.exist(err);
output.source_files.should.be.empty();
output.source_files[0].name.should.equal(path.join("svgo", "config.js"));
done();
});

});

});

0 comments on commit f9c3697

Please sign in to comment.