buster-istanbul
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -13,3 +13,4 @@ /* | ||
path = require('path'), | ||
istanbul = require('istanbul'); | ||
istanbul = require('istanbul'), | ||
minimatch = require('minimatch'); | ||
@@ -53,4 +54,17 @@ function merge(paths) { | ||
// reusable method to check for exclusions | ||
var isExcluded = function(path, excludes){ | ||
var excluded = false; | ||
if (path && excludes && excludes.length) { | ||
excluded = excludes.some(function(exclude){ | ||
return minimatch(path, exclude); | ||
}); | ||
} | ||
return excluded; | ||
} | ||
var setup = { | ||
node: function(group, instrument) { | ||
node: function(group, instrument, excludes) { | ||
coverage.hookRequire(); | ||
@@ -60,3 +74,6 @@ if (instrument === false) return; | ||
glob.sync(pattern).forEach(function(fPath) { | ||
coverage.addInstrumentCandidate(fPath); | ||
var excluded = isExcluded(fPath, excludes); | ||
if (!excluded) { | ||
coverage.addInstrumentCandidate(fPath); | ||
} | ||
}); | ||
@@ -66,3 +83,3 @@ }); | ||
browser: function(group, instrument) { | ||
browser: function(group, instrument, excludes) { | ||
var options = group.config.options; | ||
@@ -83,3 +100,6 @@ | ||
rs.addProcessor(function(resource, content){ | ||
return coverage.instrumentCode(content, resource['path'].replace(/\//, '')); | ||
var path = resource.path.replace(/\//, ''); | ||
var excluded = isExcluded(path, excludes); | ||
return excluded ? content : coverage.instrumentCode(content, path); | ||
}); | ||
@@ -126,3 +146,3 @@ }); | ||
var opts = this.options; | ||
setup[group.environment](group, opts.instrument); | ||
setup[group.environment](group, opts.instrument, opts.excludes); | ||
process.on("exit", function() { | ||
@@ -129,0 +149,0 @@ writeReports(opts.outputDirectory, opts.format || opts.formats, !!opts.silent); |
{ | ||
"name": "buster-istanbul", | ||
"description": "buster extension for istanbul code coverage.", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"homepage": "https://github.com/englishtown/buster-istanbul", | ||
@@ -32,4 +32,5 @@ "author": { | ||
"buster-core": "*", | ||
"glob": "*", | ||
"istanbul": "*", | ||
"glob": "*" | ||
"minimatch": "^2.0.1" | ||
}, | ||
@@ -36,0 +37,0 @@ "devDependencies": { |
@@ -34,3 +34,4 @@ # buster-istanbul | ||
outputDirectory: "coverage", | ||
format: "lcov" | ||
format: "lcov", | ||
excludes: ["**/*.json"] | ||
}, | ||
@@ -70,2 +71,6 @@ extensions: [ | ||
`excludes` is an array of glob paths that will be excluded from instrumentation. | ||
This can be helpful if your sources include non-js files that needed to be excluded, such as .html or .json files. | ||
Consult [node-glob](https://github.com/isaacs/node-glob) for more information on globs. | ||
Write your buster test as usual. | ||
@@ -72,0 +77,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14843
311
81
0
4
+ Addedminimatch@^2.0.1
+ Addedminimatch@2.0.10(transitive)
- Removedminimatch@3.1.2(transitive)