diff options
| -rw-r--r-- | lib/convertLcovToCoveralls.js | 11 | ||||
| -rw-r--r-- | test/convertLcovToCoveralls.js | 5 |
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js index e925343..68687bd 100644 --- a/lib/convertLcovToCoveralls.js +++ b/lib/convertLcovToCoveralls.js @@ -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); @@ -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)); diff --git a/test/convertLcovToCoveralls.js b/test/convertLcovToCoveralls.js index 7e67f3d..25a0e97 100644 --- a/test/convertLcovToCoveralls.js +++ b/test/convertLcovToCoveralls.js @@ -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(); }); - }); }); |
