2 Copyright (c) 2012, Yahoo! Inc. All rights reserved.
3 Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
6 var path = require('path'),
7 util = require('util'),
8 mkdirp = require('mkdirp'),
9 Report = require('./index'),
10 LcovOnlyReport = require('./lcovonly'),
11 HtmlReport = require('./html');
14 * a `Report` implementation that produces an LCOV coverage file and an associated HTML report from coverage objects.
15 * The name and behavior of this report is designed to ease migration for projects that currently use `yuitest_coverage`
20 * var report = require('istanbul').Report.create('lcov');
27 * @param {Object} opts optional
28 * @param {String} [opts.dir] the directory in which to the `lcov.info` file.
29 * HTML files are written in a subdirectory called `lcov-report`. Defaults to `process.cwd()`
31 function LcovReport(opts) {
34 var baseDir = path.resolve(opts.dir || process.cwd()),
35 htmlDir = path.resolve(baseDir, 'lcov-report');
38 this.lcov = new LcovOnlyReport({ dir: baseDir, watermarks: opts.watermarks });
39 this.html = new HtmlReport({ dir: htmlDir, watermarks: opts.watermarks, sourceStore: opts.sourceStore});
42 LcovReport.TYPE = 'lcov';
43 util.inherits(LcovReport, Report);
45 Report.mix(LcovReport, {
46 synopsis: function () {
47 return 'combined lcovonly and html report that generates an lcov.info file as well as HTML';
49 writeReport: function (collector, sync) {
50 var handler = this.handleDone.bind(this);
52 this.lcov.on('done', handler);
53 this.html.on('done', handler);
54 this.lcov.writeReport(collector, sync);
55 this.html.writeReport(collector, sync);
57 handleDone: function () {
59 if (this.inProgress === 0) {
65 module.exports = LcovReport;