Skip to content

Commit f9c3697

Browse files
author
Joshua Davis
committed
implemented code to parse concatenated file paths (fixes #143)
1 parent acc1fd8 commit f9c3697

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/convertLcovToCoveralls.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ var convertLcovFileObject = function(file, filepath){
2323
coverage : coverage };
2424
};
2525

26+
var cleanFilePath = function(file) {
27+
if (file.indexOf('!') > -1) {
28+
var regex = /^(.*!)(.*)$/g;
29+
var matches = regex.exec(file);
30+
return matches[matches.length-1];
31+
}
32+
33+
return file;
34+
};
35+
2636
var convertLcovToCoveralls = function(input, options, cb){
2737
var filepath = options.filepath || '';
2838
logger.debug("in: ", filepath);
@@ -61,6 +71,7 @@ var convertLcovToCoveralls = function(input, options, cb){
6171
postJson.service_pull_request = options.service_pull_request;
6272
}
6373
parsed.forEach(function(file){
74+
file.file = cleanFilePath(file.file);
6475
var currentFilePath = path.resolve(filepath, file.file);
6576
if (fs.existsSync(currentFilePath)) {
6677
postJson.source_files.push(convertLcovFileObject(file, filepath));

test/convertLcovToCoveralls.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,16 @@ describe("convertLcovToCoveralls", function(){
134134
};
135135

136136
var originalExistsSync = fs.existsSync;
137-
fs.existsSync = function () { return false; };
137+
fs.existsSync = function () { return true; };
138138

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

143143
should.not.exist(err);
144-
output.source_files.should.be.empty();
144+
output.source_files[0].name.should.equal(path.join("svgo", "config.js"));
145145
done();
146146
});
147-
148147
});
149148

150149
});

0 commit comments

Comments
 (0)