From 593d1be7855993f0ec4c34fbf8e7f2673304edd5 Mon Sep 17 00:00:00 2001 From: Levi Yurkowicz Date: Thu, 31 Oct 2019 17:51:47 -0400 Subject: add ability to parse cobertura files --- lib/convertLcovToCoveralls.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js index 521e749..815c85b 100644 --- a/lib/convertLcovToCoveralls.js +++ b/lib/convertLcovToCoveralls.js @@ -1,6 +1,7 @@ var TRAVIS_JOB_ID = process.env.TRAVIS_JOB_ID || 'unknown'; var fs = require('fs'); var lcovParse = require('lcov-parse'); +var coberturaParse = require('cobertura-parse'); var path = require('path'); var logger = require('./logger')(); @@ -47,11 +48,13 @@ var cleanFilePath = function(file) { var convertLcovToCoveralls = function(input, options, cb){ var filepath = options.filepath || ''; + var filetype = options.filetype || 'lcov'; + var parser = filetype === 'cobertura' ? coberturaParse.parseContent : lcovParse; logger.debug("in: ", filepath); filepath = path.resolve(process.cwd(), filepath); - lcovParse(input, function(err, parsed){ + parser(input, function(err, parsed){ if (err){ - logger.error("error from lcovParse: ", err); + logger.error("error from " + filetype + "Parse: ", err); logger.error("input: ", input); return cb(err); } -- cgit v1.2.3