Skip to content

Commit 5271959

Browse files
committed
allow for any options to be passed
1 parent cdebbd7 commit 5271959

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

lib/coverage.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ var path = require('path'),
33

44
var istanbul,
55
collector,
6-
coveragePath;
6+
options = {
7+
dir: 'coverage'
8+
};
79

810
try {
911
istanbul = require('istanbul');
1012
} catch (e) {}
1113

12-
exports.setup = function(path) {
14+
exports.setup = function(opts) {
1315
collector = new istanbul.Collector();
14-
coveragePath = typeof path === 'string' ? path : 'coverage';
16+
17+
options = _.extend(options, opts);
18+
options.dir = path.resolve(options.dir);
1519
};
1620

1721
exports.add = function(coverage) {
@@ -33,9 +37,8 @@ exports.report = function() {
3337
var opts, Report, reports;
3438

3539
if (collector) {
36-
opts = {dir: path.resolve(coveragePath)};
3740
Report = istanbul.Report;
38-
reports = [Report.create('lcov', opts), Report.create('json', opts)];
41+
reports = [Report.create('lcov', options), Report.create('json', options)];
3942
reports.forEach(function(rep) {
4043
rep.writeReport(collector, true);
4144
});

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,4 @@ Some tests examples
244244

245245
### Coverage
246246

247-
Code coverage via Istanbul. To utilize, install `istanbul` and set option `coverage: true` or give a path where to store report `coverage: "coverage/path"` or pass `--cov` parameter in the shell. Coverage calculations based on code and tests passed to `node-qunit`.
247+
Code coverage via Istanbul. To utilize, install `istanbul` and set option `coverage: true` or give a path where to store report `coverage: {dir: "coverage/path"}` or pass `--cov` parameter in the shell. Coverage calculations based on code and tests passed to `node-qunit`.

0 commit comments

Comments
 (0)