Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / istanbul / lib / report / lcov.js
1 /*
2  Copyright (c) 2012, Yahoo! Inc.  All rights reserved.
3  Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
4  */
5
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');
12
13 /**
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`
16  *
17  * Usage
18  * -----
19  *
20  *      var report = require('istanbul').Report.create('lcov');
21  *
22  *
23  * @class LcovReport
24  * @extends Report
25  * @module report
26  * @constructor
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()`
30  */
31 function LcovReport(opts) {
32     Report.call(this);
33     opts = opts || {};
34     var baseDir = path.resolve(opts.dir || process.cwd()),
35         htmlDir = path.resolve(baseDir, 'lcov-report');
36
37     mkdirp.sync(baseDir);
38     this.lcov = new LcovOnlyReport({ dir: baseDir, watermarks: opts.watermarks });
39     this.html = new HtmlReport({ dir: htmlDir, watermarks: opts.watermarks, sourceStore: opts.sourceStore});
40 }
41
42 LcovReport.TYPE = 'lcov';
43 util.inherits(LcovReport, Report);
44
45 Report.mix(LcovReport, {
46     synopsis: function () {
47         return 'combined lcovonly and html report that generates an lcov.info file as well as HTML';
48     },
49     writeReport: function (collector, sync) {
50         var handler = this.handleDone.bind(this);
51         this.inProgress = 2;
52         this.lcov.on('done', handler);
53         this.html.on('done', handler);
54         this.lcov.writeReport(collector, sync);
55         this.html.writeReport(collector, sync);
56     },
57     handleDone: function () {
58         this.inProgress -= 1;
59         if (this.inProgress === 0) {
60             this.emit('done');
61         }
62     }
63 });
64
65 module.exports = LcovReport;