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 |
1 |
var path = require('path'), |
7 |
|
mkdirp = require('mkdirp'), |
8 |
|
util = require('util'), |
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 |
|
* @constructor |
26 |
|
* @param {Object} opts optional |
27 |
|
* @param {String} [opts.dir] the directory in which to the `lcov.info` file. HTML files are written in a subdirectory called `lcov-report`. Defaults to `process.cwd()` |
28 |
|
*/ |
29 |
1 |
function LcovReport(opts) { |
30 |
2 |
Report.call(this); |
31 |
2 |
opts = opts || {}; |
32 |
2 |
var baseDir = path.resolve(opts.dir || process.cwd()), |
33 |
|
htmlDir = path.resolve(baseDir, 'lcov-report'); |
34 |
|
|
35 |
2 |
mkdirp.sync(baseDir); |
36 |
2 |
this.lcov = new LcovOnlyReport({ dir: baseDir }); |
37 |
2 |
this.html = new HtmlReport({ dir: htmlDir }); |
38 |
|
} |
39 |
|
|
40 |
1 |
LcovReport.TYPE = 'lcov'; |
41 |
|
|
42 |
1 |
Report.mix(LcovReport, { |
43 |
|
writeReport: function (collector, sync) { |
44 |
2 |
this.lcov.writeReport(collector, sync); |
45 |
2 |
this.html.writeReport(collector, sync); |
46 |
|
} |
47 |
|
}); |
48 |
|
|
49 |
1 |
module.exports = LcovReport; |
50 |
|
|