From c0213e0d0007bbccf626d2ccd4bb2a7de6f84580 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Thu, 26 Feb 2015 14:33:17 -0500 Subject: [PATCH] Use upstream lcov-reporter.js --- Gruntfile.js | 2 +- package.json | 2 +- test/lcov-reporter.js | 44 ------------------------------------------- 3 files changed, 2 insertions(+), 46 deletions(-) delete mode 100644 test/lcov-reporter.js diff --git a/Gruntfile.js b/Gruntfile.js index 2daf0608..912be939 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -75,7 +75,7 @@ module.exports = function(grunt) { cov: { src: ['test/coverage.html'], options: { - reporter: 'test/lcov-reporter.js', + reporter: 'node_modules/mocha-lcov-reporter/lib/lcov.js', output: 'build/bundled.lcov' } } diff --git a/package.json b/package.json index eb7a2400..b98ffaa4 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "grunt-mocha-test": "^0.12.7", "lcov-parse": "0.0.9", "mocha": "^2.1.0", - "mocha-lcov-reporter": "0.0.1", + "mocha-lcov-reporter": ">=0.0.2", "parse-data-uri": "^0.2.0", "react-tools": "^0.12.2", "reactify": "^1.0.0", diff --git a/test/lcov-reporter.js b/test/lcov-reporter.js deleted file mode 100644 index fb4c16dc..00000000 --- a/test/lcov-reporter.js +++ /dev/null @@ -1,44 +0,0 @@ -// See https://github.com/StevenLooman/mocha-lcov-reporter/pull/7 - -/** - * Expose `LCov`. - */ - -exports = module.exports = LCov; - -/** - * Initialize a new LCOV reporter. - * File format of LCOV can be found here: http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php - * The reporter is built after this parser: https://raw.github.com/SonarCommunity/sonar-javascript/master/sonar-javascript-plugin/src/main/java/org/sonar/plugins/javascript/coverage/LCOVParser.java - * - * @param {Runner} runner - * @api public - */ - -function LCov(runner) { - runner.on('end', function(){ - // In a browser context, coverage will be in window.$jscoverage. - var g = typeof(global) != 'undefined' ? global : window; - var cov = g._$jscoverage || {}; - - for (var filename in cov) { - var data = cov[filename]; - reportFile(filename, data); - } - }); -} - -function reportFile(filename, data) { - process.stdout.write('SF:' + filename + '\n'); - - data.source.forEach(function(line, num) { - // increase the line number, as JS arrays are zero-based - num++; - - if (data[num] !== undefined) { - process.stdout.write('DA:' + num + ',' + data[num] + '\n'); - } - }); - - process.stdout.write('end_of_record\n'); -}