Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ exports.instrument = function(options) {
var matcher, instrumenter;

matcher = function (file) {
return file === options.code.path;
var files = options.coverage.files;
if (files) {
files = Array.isArray(files) ? files : [files];
return files.some(function(f) {
if (typeof f === 'string') return file.indexOf(f) === 0;
else if (f instanceof RegExp) return f.test(file);
else throw new Error("invalid entry in options.coverage.files: " + typeof f);
});
} else {
return file === options.code.path;
}
}
instrumenter = new istanbul.Instrumenter();
istanbul.hook.hookRequire(matcher, instrumenter.instrumentSync.bind(instrumenter));
Expand Down