diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:38:50 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:40:43 +0200 |
commit | 7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch) | |
tree | 6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/test-exclude | |
parent | 963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff) |
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/test-exclude')
-rw-r--r-- | node_modules/test-exclude/CHANGELOG.md | 179 | ||||
-rw-r--r-- | node_modules/test-exclude/LICENSE.txt | 14 | ||||
-rw-r--r-- | node_modules/test-exclude/README.md | 56 | ||||
-rw-r--r-- | node_modules/test-exclude/index.js | 115 | ||||
-rw-r--r-- | node_modules/test-exclude/package.json | 47 |
5 files changed, 411 insertions, 0 deletions
diff --git a/node_modules/test-exclude/CHANGELOG.md b/node_modules/test-exclude/CHANGELOG.md new file mode 100644 index 000000000..e6a4ee3d2 --- /dev/null +++ b/node_modules/test-exclude/CHANGELOG.md @@ -0,0 +1,179 @@ +# Change Log + +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.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) + + +### Features + +* add possibility to filter coverage maps when running reports post-hoc ([#24](https://github.com/istanbuljs/istanbuljs/issues/24)) ([e1c99d6](https://github.com/istanbuljs/test-exclude/commit/e1c99d6)) + + + + +<a name="4.0.3"></a> +## [4.0.3](https://github.com/istanbuljs/test-exclude/compare/test-exclude@4.0.2...test-exclude@4.0.3) (2017-03-21) + +<a name="4.0.2"></a> +## [4.0.2](https://github.com/istanbuljs/test-exclude/compare/test-exclude@4.0.0...test-exclude@4.0.2) (2017-03-21) + +<a name="4.0.0"></a> +# [4.0.0](https://github.com/istanbuljs/test-exclude/compare/v3.3.0...v4.0.0) (2017-01-19) + + +### Features + +* add coverage to default excludes ([#23](https://github.com/istanbuljs/test-exclude/issues/23)) ([59e8bbf](https://github.com/istanbuljs/test-exclude/commit/59e8bbf)) + + +### BREAKING CHANGES + +* additional coverage folder is now excluded + + + +<a name="3.3.0"></a> +# [3.3.0](https://github.com/istanbuljs/test-exclude/compare/v3.2.2...v3.3.0) (2016-11-22) + + +### Features + +* allow include/exclude rules to be a string rather than array ([#22](https://github.com/istanbuljs/test-exclude/issues/22)) ([f8f99c6](https://github.com/istanbuljs/test-exclude/commit/f8f99c6)) + + + +<a name="3.2.2"></a> +## [3.2.2](https://github.com/istanbuljs/test-exclude/compare/v3.2.1...v3.2.2) (2016-11-14) + + +### Bug Fixes + +* we no longer need to add node_modules/** rule ([d0cfbc3](https://github.com/istanbuljs/test-exclude/commit/d0cfbc3)) + + + +<a name="3.2.1"></a> +## [3.2.1](https://github.com/istanbuljs/test-exclude/compare/v3.2.0...v3.2.1) (2016-11-14) + + +### Bug Fixes + +* fix bug matching files in root, introduced by dotfiles setting ([27b249c](https://github.com/istanbuljs/test-exclude/commit/27b249c)) + + + +<a name="3.2.0"></a> +# [3.2.0](https://github.com/istanbuljs/test-exclude/compare/v3.1.0...v3.2.0) (2016-11-14) + + +### Features + +* adds *.test.*.js exclude rule ([#20](https://github.com/istanbuljs/test-exclude/issues/20)) ([34f5cba](https://github.com/istanbuljs/test-exclude/commit/34f5cba)) + + + +<a name="3.1.0"></a> +# [3.1.0](https://github.com/istanbuljs/test-exclude/compare/v3.0.0...v3.1.0) (2016-11-14) + + +### Features + +* we now support dot folders ([f2c1598](https://github.com/istanbuljs/test-exclude/commit/f2c1598)) + + + +<a name="3.0.0"></a> +# [3.0.0](https://github.com/istanbuljs/test-exclude/compare/v2.1.3...v3.0.0) (2016-11-13) + + +### Features + +* always exclude node_modules ([#18](https://github.com/istanbuljs/test-exclude/issues/18)) ([b86d144](https://github.com/istanbuljs/test-exclude/commit/b86d144)) + + +### BREAKING CHANGES + +* `**/node_modules/**` is again added by default, but can be counteracted with `!**/node_modules/**`. + + + +<a name="2.1.3"></a> +## [2.1.3](https://github.com/istanbuljs/test-exclude/compare/v2.1.2...v2.1.3) (2016-09-30) + + +### Bug Fixes + +* switch lodash.assign to object-assign ([#16](https://github.com/istanbuljs/test-exclude/issues/16)) ([45a5488](https://github.com/istanbuljs/test-exclude/commit/45a5488)) + + + +<a name="2.1.2"></a> +## [2.1.2](https://github.com/istanbuljs/test-exclude/compare/v2.1.1...v2.1.2) (2016-08-31) + + +### Bug Fixes + +* **exclude-config:** Use the defaultExcludes for anything passed in that is not an array ([#15](https://github.com/istanbuljs/test-exclude/issues/15)) ([227042f](https://github.com/istanbuljs/test-exclude/commit/227042f)) + + + +<a name="2.1.1"></a> +# [2.1.1](https://github.com/istanbuljs/test-exclude/compare/v2.1.0...v2.1.1) (2016-08-12) + + +### Bug Fixes + +* it should be possible to cover the node_modules folder ([#13](https://github.com/istanbuljs/test-exclude/issues/13)) ([09f2788](https://github.com/istanbuljs/test-exclude/commit/09f2788)) + + +<a name="2.1.0"></a> +# [2.1.0](https://github.com/istanbuljs/test-exclude/compare/v2.0.0...v2.1.0) (2016-08-12) + + +### Features + +* export defaultExclude, so that it can be used in yargs' default settings ([#12](https://github.com/istanbuljs/test-exclude/issues/12)) ([5b3743b](https://github.com/istanbuljs/test-exclude/commit/5b3743b)) + + + +<a name="2.0.0"></a> +# [2.0.0](https://github.com/istanbuljs/test-exclude/compare/v1.1.0...v2.0.0) (2016-08-12) + + +### Bug Fixes + +* use Array#reduce and remove unneeded branch in prepGlobPatterns ([#5](https://github.com/istanbuljs/test-exclude/issues/5)) ([c0f0f59](https://github.com/istanbuljs/test-exclude/commit/c0f0f59)) + + +### Features + +* don't exclude anything when empty array passed ([#11](https://github.com/istanbuljs/test-exclude/issues/11)) ([200ec07](https://github.com/istanbuljs/test-exclude/commit/200ec07)) + + +### BREAKING CHANGES + +* we now allow an empty array to be passed in, making it possible to disable the default exclude rules -- we will need to be mindful when pulling this logic into nyc. + + + +<a name="1.1.0"></a> +# [1.1.0](https://github.com/bcoe/test-exclude/compare/v1.0.0...v1.1.0) (2016-06-08) + + +### Features + +* set configFound if we find a configuration key in package.json ([#2](https://github.com/bcoe/test-exclude/issues/2)) ([64da7b9](https://github.com/bcoe/test-exclude/commit/64da7b9)) + + + +<a name="1.0.0"></a> +# 1.0.0 (2016-06-06) + + +### Features + +* initial commit, pulled over some of the functionality from nyc ([3f1fce3](https://github.com/bcoe/test-exclude/commit/3f1fce3)) +* you can now load include/exclude logic from a package.json stanza ([#1](https://github.com/bcoe/test-exclude/issues/1)) ([29b543d](https://github.com/bcoe/test-exclude/commit/29b543d)) diff --git a/node_modules/test-exclude/LICENSE.txt b/node_modules/test-exclude/LICENSE.txt new file mode 100644 index 000000000..836440bef --- /dev/null +++ b/node_modules/test-exclude/LICENSE.txt @@ -0,0 +1,14 @@ +Copyright (c) 2016, Contributors + +Permission to use, copy, modify, and/or distribute this software +for any purpose with or without fee is hereby granted, provided +that the above copyright notice and this permission notice +appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE +LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES +OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/test-exclude/README.md b/node_modules/test-exclude/README.md new file mode 100644 index 000000000..fd844f820 --- /dev/null +++ b/node_modules/test-exclude/README.md @@ -0,0 +1,56 @@ +# test-exclude + +The file include/exclude logic used by [nyc](https://github.com/istanbuljs/nyc). + +[![Build Status](https://travis-ci.org/istanbuljs/test-exclude.svg)](https://travis-ci.org/istanbuljs/test-exclude) +[![Coverage Status](https://coveralls.io/repos/github/istanbuljs/test-exclude/badge.svg?branch=master)](https://coveralls.io/github/istanbuljs/test-exclude?branch=master) +[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version) +[![Greenkeeper badge](https://badges.greenkeeper.io/istanbuljs/test-exclude.svg)](https://greenkeeper.io/) + +## Usage + +```js +const exclude = require('test-exclude') +if (exclude().shouldInstrument('./foo.js')) { + // let's instrument this file for test coverage! +} +``` + +_you can load configuration from a key in package.json:_ + +_package.json_ + +```json +{ + "name": "awesome-module", + "test": { + "include": ["**/index.js"] + } +} +``` + +_app.js_ + +```js +const exclude = require('test-exclude') +if (exclude({configKey: 'test'}).shouldInstrument('./index.js')) { + // let's instrument this file for test coverage! +} +``` + +## Including node_modules folder + +by default the `node_modules` folder is added to all groups of +exclude rules. In the rare case that you wish to instrument files +stored in `node_modules`, a negative glob can be used: + +```js +const exclude = require('test-exclude') +const e = exclude({ + exclude: ['!**/node_modules/**'] +}) +``` + +## License + +ISC diff --git a/node_modules/test-exclude/index.js b/node_modules/test-exclude/index.js new file mode 100644 index 000000000..ccc0957c2 --- /dev/null +++ b/node_modules/test-exclude/index.js @@ -0,0 +1,115 @@ +const assign = require('object-assign') +const arrify = require('arrify') +const micromatch = require('micromatch') +const path = require('path') +const readPkgUp = require('read-pkg-up') +const requireMainFilename = require('require-main-filename') + +function TestExclude (opts) { + assign(this, { + cwd: process.cwd(), + include: false, + relativePath: true, + configKey: null, // the key to load config from in package.json. + configPath: null, // optionally override requireMainFilename. + configFound: false + }, opts) + + if (typeof this.include === 'string') this.include = [this.include] + if (typeof this.exclude === 'string') this.exclude = [this.exclude] + + if (!this.include && !this.exclude && this.configKey) { + assign(this, this.pkgConf(this.configKey, this.configPath)) + } + + if (!this.exclude || !Array.isArray(this.exclude)) { + this.exclude = exportFunc.defaultExclude + } + + if (this.include && this.include.length > 0) { + this.include = prepGlobPatterns(arrify(this.include)) + } else { + this.include = false + } + + if (!this.removeNegatedModuleExclude() && this.exclude.indexOf('**/node_modules/**') === -1) { + this.exclude.push('**/node_modules/**') + } + + this.exclude = prepGlobPatterns( + [].concat(arrify(this.exclude)) + ) +} + +// 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 + 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 moduleExcludeNegated +} + +TestExclude.prototype.shouldInstrument = function (filename, relFile) { + var pathToCheck = filename + + if (this.relativePath) { + relFile = relFile || path.relative(this.cwd, filename) + + // Don't instrument files that are outside of the current working directory. + if (/^\.\./.test(path.relative(this.cwd, filename))) return false + + pathToCheck = relFile.replace(/^\.[\\/]/, '') // remove leading './' or '.\'. + } + + return (!this.include || micromatch.any(pathToCheck, this.include, {dotfiles: true})) && !micromatch.any(pathToCheck, this.exclude, {dotfiles: true}) +} + +TestExclude.prototype.pkgConf = function (key, path) { + const obj = readPkgUp.sync({ + cwd: path || requireMainFilename(require) + }) + + if (obj.pkg && obj.pkg[key] && typeof obj.pkg[key] === 'object') { + this.configFound = true + return obj.pkg[key] + } else { + return {} + } +} + +function prepGlobPatterns (patterns) { + return patterns.reduce(function (result, pattern) { + // Allow gitignore style of directory exclusion + if (!/\/\*\*$/.test(pattern)) { + result = result.concat(pattern.replace(/\/$/, '') + '/**') + } + + // Any rules of the form **/foo.js, should also match foo.js. + if (/^\*\*\//.test(pattern)) { + result = result.concat(pattern.replace(/^\*\*\//, '')) + } + + return result.concat(pattern) + }, []) +} + +var exportFunc = function (opts) { + return new TestExclude(opts) +} + +exportFunc.defaultExclude = [ + 'coverage/**', + 'test/**', + 'test{,-*}.js', + '**/*.test.js', + '**/__tests__/**', + '**/node_modules/**' +] + +module.exports = exportFunc diff --git a/node_modules/test-exclude/package.json b/node_modules/test-exclude/package.json new file mode 100644 index 000000000..a73a0511d --- /dev/null +++ b/node_modules/test-exclude/package.json @@ -0,0 +1,47 @@ +{ + "name": "test-exclude", + "version": "4.1.0", + "description": "test for inclusion or exclusion of paths using pkg-conf and globs", + "main": "index.js", + "files": [ + "index.js" + ], + "scripts": { + "pretest": "standard", + "test": "mocha" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/istanbuljs/test-exclude.git" + }, + "keywords": [ + "exclude", + "include", + "glob", + "package", + "config" + ], + "author": "Ben Coe <ben@npmjs.com>", + "license": "ISC", + "bugs": { + "url": "https://github.com/istanbuljs/test-exclude/issues" + }, + "homepage": "https://github.com/istanbuljs/test-exclude#readme", + "devDependencies": { + "chai": "^3.5.0", + "mocha": "^3.1.2", + "standard": "^9.0.0" + }, + "dependencies": { + "arrify": "^1.0.1", + "micromatch": "^2.3.11", + "object-assign": "^4.1.0", + "read-pkg-up": "^1.0.1", + "require-main-filename": "^1.0.1" + }, + "greenkeeper": { + "ignore": [ + "read-pkg-up" + ] + } +} |