test-exclude
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="4.1.1"></a> | ||
## [4.1.1](https://github.com/istanbuljs/istanbuljs/compare/test-exclude@4.1.0...test-exclude@4.1.1) (2017-05-27) | ||
### Bug Fixes | ||
* add more general support for negated exclude rules ([#58](https://github.com/istanbuljs/istanbuljs/issues/58)) ([08445db](https://github.com/istanbuljs/istanbuljs/commit/08445db)) | ||
<a name="4.1.0"></a> | ||
@@ -8,0 +19,0 @@ # [4.1.0](https://github.com/istanbuljs/test-exclude/compare/test-exclude@4.0.3...test-exclude@4.1.0) (2017-04-29) |
44
index.js
@@ -35,3 +35,3 @@ const assign = require('object-assign') | ||
if (!this.removeNegatedModuleExclude() && this.exclude.indexOf('**/node_modules/**') === -1) { | ||
if (this.exclude.indexOf('**/node_modules/**') === -1) { | ||
this.exclude.push('**/node_modules/**') | ||
@@ -43,16 +43,32 @@ } | ||
) | ||
this.handleNegation() | ||
} | ||
// if a glob has been provided that explicitly negates | ||
// the **/node_modules/** default exclude rule, remove it from | ||
// excludes but don't add the default exclude rule. | ||
TestExclude.prototype.removeNegatedModuleExclude = function () { | ||
var moduleExcludeNegated = false | ||
// handle the special case of negative globs | ||
// (!**foo/bar); we create a new this.excludeNegated set | ||
// of rules, which is applied after excludes and we | ||
// move excluded include rules into this.excludes. | ||
TestExclude.prototype.handleNegation = function () { | ||
if (Array.isArray(this.include)) { | ||
const includeNegated = this.include.filter(function (e) { | ||
return e.charAt(0) === '!' | ||
}).map(function (e) { | ||
return e.slice(1) | ||
}) | ||
this.exclude.push.apply(this.exclude, prepGlobPatterns(includeNegated)) | ||
this.include = this.include.filter(function (e) { | ||
return e.charAt(0) !== '!' | ||
}) | ||
} | ||
this.excludeNegated = this.exclude.filter(function (e) { | ||
return e.charAt(0) === '!' | ||
}).map(function (e) { | ||
return e.slice(1) | ||
}) | ||
this.exclude = this.exclude.filter(function (e) { | ||
var negated = !!micromatch('./node_modules/foo.js', e, {nonegate: false}).length !== | ||
!!micromatch('./node_modules/foo.js', e, {nonegate: true}).length | ||
if (negated) moduleExcludeNegated = true | ||
return !negated | ||
return e.charAt(0) !== '!' | ||
}) | ||
return moduleExcludeNegated | ||
this.excludeNegated = prepGlobPatterns(this.excludeNegated) | ||
} | ||
@@ -72,3 +88,7 @@ | ||
return (!this.include || micromatch.any(pathToCheck, this.include, {dotfiles: true})) && !micromatch.any(pathToCheck, this.exclude, {dotfiles: true}) | ||
return ( | ||
!this.include || | ||
micromatch.any(pathToCheck, this.include, {dotfiles: true})) && | ||
(!micromatch.any(pathToCheck, this.exclude, {dotfiles: true}) || | ||
micromatch.any(pathToCheck, this.excludeNegated, {dotfiles: true})) | ||
} | ||
@@ -75,0 +95,0 @@ |
{ | ||
"name": "test-exclude", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "test for inclusion or exclusion of paths using pkg-conf and globs", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/istanbuljs/test-exclude.git" | ||
"url": "git+https://github.com/istanbuljs/istanbuljs.git" | ||
}, | ||
@@ -28,5 +28,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/istanbuljs/test-exclude/issues" | ||
"url": "https://github.com/istanbuljs/istanbuljs/issues" | ||
}, | ||
"homepage": "https://github.com/istanbuljs/test-exclude#readme", | ||
"homepage": "https://github.com/istanbuljs/istanbuljs#readme", | ||
"devDependencies": { | ||
@@ -33,0 +33,0 @@ "chai": "^3.5.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
13127
112
0