Skip to content

Commit b53a7ee

Browse files
committed
use options.coverage.files + allow array of strings or regexps
1 parent 60c869f commit b53a7ee

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

lib/coverage.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,17 @@ exports.instrument = function(options) {
5454
var matcher, instrumenter;
5555

5656
matcher = function (file) {
57-
if (typeof options.coverage === 'string') return file.indexOf(options.coverage) === 0;
58-
else if (options.coverage instanceof RegExp) return options.coverage.test(file);
59-
else return file === options.code.path;
57+
var files = options.coverage.files;
58+
if (files) {
59+
files = Array.isArray(files) ? files : [files];
60+
return files.some(function(f) {
61+
if (typeof f === 'string') return file.indexOf(f) === 0;
62+
else if (f instanceof RegExp) return f.test(file);
63+
else throw new Error("invalid entry in options.coverage.files: " + typeof f);
64+
});
65+
} else {
66+
return file === options.code.path;
67+
}
6068
}
6169
instrumenter = new istanbul.Instrumenter();
6270
istanbul.hook.hookRequire(matcher, instrumenter.instrumentSync.bind(instrumenter));

0 commit comments

Comments
 (0)