diff options
Diffstat (limited to 'node_modules/test-exclude')
-rw-r--r-- | node_modules/test-exclude/CHANGELOG.md | 11 | ||||
-rw-r--r-- | node_modules/test-exclude/index.js | 44 | ||||
-rw-r--r-- | node_modules/test-exclude/package.json | 8 |
3 files changed, 47 insertions, 16 deletions
diff --git a/node_modules/test-exclude/CHANGELOG.md b/node_modules/test-exclude/CHANGELOG.md index e6a4ee3d2..5a7721691 100644 --- a/node_modules/test-exclude/CHANGELOG.md +++ b/node_modules/test-exclude/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +<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> # [4.1.0](https://github.com/istanbuljs/test-exclude/compare/test-exclude@4.0.3...test-exclude@4.1.0) (2017-04-29) diff --git a/node_modules/test-exclude/index.js b/node_modules/test-exclude/index.js index ccc0957c2..9c23a5865 100644 --- a/node_modules/test-exclude/index.js +++ b/node_modules/test-exclude/index.js @@ -32,27 +32,43 @@ function TestExclude (opts) { this.include = false } - if (!this.removeNegatedModuleExclude() && this.exclude.indexOf('**/node_modules/**') === -1) { + if (this.exclude.indexOf('**/node_modules/**') === -1) { this.exclude.push('**/node_modules/**') } this.exclude = prepGlobPatterns( [].concat(arrify(this.exclude)) ) + + 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) } TestExclude.prototype.shouldInstrument = function (filename, relFile) { @@ -67,7 +83,11 @@ TestExclude.prototype.shouldInstrument = function (filename, relFile) { pathToCheck = relFile.replace(/^\.[\\/]/, '') // remove leading './' or '.\'. } - 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})) } TestExclude.prototype.pkgConf = function (key, path) { diff --git a/node_modules/test-exclude/package.json b/node_modules/test-exclude/package.json index a73a0511d..ddfb5492b 100644 --- a/node_modules/test-exclude/package.json +++ b/node_modules/test-exclude/package.json @@ -1,6 +1,6 @@ { "name": "test-exclude", - "version": "4.1.0", + "version": "4.1.1", "description": "test for inclusion or exclusion of paths using pkg-conf and globs", "main": "index.js", "files": [ @@ -12,7 +12,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/istanbuljs/test-exclude.git" + "url": "git+https://github.com/istanbuljs/istanbuljs.git" }, "keywords": [ "exclude", @@ -24,9 +24,9 @@ "author": "Ben Coe <ben@npmjs.com>", "license": "ISC", "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": { "chai": "^3.5.0", "mocha": "^3.1.2", |