test-exclude
Advanced tools
Comparing version 5.2.3 to 6.0.0-alpha.0
@@ -6,2 +6,27 @@ # Change Log | ||
# [6.0.0-alpha.0](https://github.com/istanbuljs/istanbuljs/compare/test-exclude@5.2.3...test-exclude@6.0.0-alpha.0) (2019-06-19) | ||
### Bug Fixes | ||
* **win32:** Detect files on different drive as outside project ([#422](https://github.com/istanbuljs/istanbuljs/issues/422)) ([5b4ee88](https://github.com/istanbuljs/istanbuljs/commit/5b4ee88)), closes [#418](https://github.com/istanbuljs/istanbuljs/issues/418) | ||
* Ignore tests matching *.cjs, *.mjs and *.ts by default ([#381](https://github.com/istanbuljs/istanbuljs/issues/381)) ([0f077c2](https://github.com/istanbuljs/istanbuljs/commit/0f077c2)) | ||
### Features | ||
* ignore files under test**s** directories by default ([#419](https://github.com/istanbuljs/istanbuljs/issues/419)) ([8ad5fd2](https://github.com/istanbuljs/istanbuljs/commit/8ad5fd2)) | ||
* Remove configuration loading functionality ([#398](https://github.com/istanbuljs/istanbuljs/issues/398)) ([f5c93c3](https://github.com/istanbuljs/istanbuljs/commit/f5c93c3)), closes [#392](https://github.com/istanbuljs/istanbuljs/issues/392) | ||
* Update dependencies, require Node.js 8 ([#401](https://github.com/istanbuljs/istanbuljs/issues/401)) ([bf3a539](https://github.com/istanbuljs/istanbuljs/commit/bf3a539)) | ||
### BREAKING CHANGES | ||
* Node.js 8 is now required | ||
* Remove configuration loading functionality | ||
## [5.2.3](https://github.com/istanbuljs/istanbuljs/compare/test-exclude@5.2.2...test-exclude@5.2.3) (2019-04-24) | ||
@@ -8,0 +33,0 @@ |
42
index.js
@@ -0,6 +1,8 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const glob = require('glob'); | ||
const minimatch = require('minimatch'); | ||
const readPkgUp = require('read-pkg-up'); | ||
const requireMainFilename = require('require-main-filename'); | ||
const defaultExclude = require('./default-exclude'); | ||
const isOutsideDir = require('./is-outside-dir'); | ||
@@ -15,5 +17,2 @@ class TestExclude { | ||
relativePath: true, | ||
configKey: null, // the key to load config from in package.json. | ||
configPath: null, // optionally override requireMainFilename. | ||
configFound: false, | ||
excludeNodeModules: true, | ||
@@ -42,8 +41,4 @@ extension: false | ||
if (!this.include && !this.exclude && this.configKey) { | ||
Object.assign(this, this.pkgConf(this.configKey, this.configPath)); | ||
} | ||
if (!this.exclude || !Array.isArray(this.exclude)) { | ||
this.exclude = exportFunc.defaultExclude; | ||
this.exclude = defaultExclude; | ||
} | ||
@@ -104,3 +99,3 @@ | ||
// Don't instrument files that are outside of the current working directory. | ||
if (/^\.\./.test(path.relative(this.cwd, filename))) { | ||
if (isOutsideDir(this.cwd, filename)) { | ||
return false; | ||
@@ -120,15 +115,2 @@ } | ||
pkgConf(key, path) { | ||
const cwd = path || requireMainFilename(require); | ||
const obj = readPkgUp.sync({ cwd }); | ||
if (obj.pkg && obj.pkg[key] && typeof obj.pkg[key] === 'object') { | ||
this.configFound = true; | ||
return obj.pkg[key]; | ||
} | ||
return {}; | ||
} | ||
globSync(cwd = this.cwd) { | ||
@@ -178,14 +160,4 @@ const globPatterns = getExtensionPattern(this.extension || []); | ||
const devConfigs = ['ava', 'babel', 'jest', 'nyc', 'rollup', 'webpack']; | ||
exportFunc.defaultExclude = defaultExclude; | ||
exportFunc.defaultExclude = [ | ||
'coverage/**', | ||
'packages/*/test/**', | ||
'test/**', | ||
'test{,-*}.js', | ||
'**/*{.,-}test.js', | ||
'**/__tests__/**', | ||
`**/{${devConfigs.join()}}.config.js` | ||
]; | ||
module.exports = exportFunc; |
{ | ||
"name": "test-exclude", | ||
"version": "5.2.3", | ||
"description": "test for inclusion or exclusion of paths using pkg-conf and globs", | ||
"version": "6.0.0-alpha.0", | ||
"description": "test for inclusion or exclusion of paths using globs", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js" | ||
"*.js", | ||
"!nyc.config.js" | ||
], | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "nyc mocha" | ||
}, | ||
@@ -30,11 +31,14 @@ "repository": { | ||
"dependencies": { | ||
"glob": "^7.1.3", | ||
"minimatch": "^3.0.4", | ||
"read-pkg-up": "^4.0.0", | ||
"require-main-filename": "^2.0.0" | ||
"glob": "^7.1.4", | ||
"minimatch": "^3.0.4" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"mocha": "^6.1.4", | ||
"nyc": "^14.1.1" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=8" | ||
}, | ||
"gitHead": "90e60cc47833bb780680f916488ca24f0be36ca2" | ||
"gitHead": "2e885073a9398806c9b8763dd39418398182ca34" | ||
} |
@@ -19,24 +19,2 @@ # test-exclude | ||
_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 | ||
@@ -43,0 +21,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18773
2
9
159
3
1
35
- Removedread-pkg-up@^4.0.0
- Removedrequire-main-filename@^2.0.0
- Removederror-ex@1.3.2(transitive)
- Removedfind-up@3.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.13.1(transitive)
- Removedjson-parse-better-errors@1.0.2(transitive)
- Removedload-json-file@4.0.0(transitive)
- Removedlocate-path@3.0.0(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@3.0.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedparse-json@4.0.0(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@3.0.0(transitive)
- Removedpify@3.0.0(transitive)
- Removedread-pkg@3.0.0(transitive)
- Removedread-pkg-up@4.0.0(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsemver@5.7.2(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.17(transitive)
- Removedstrip-bom@3.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
Updatedglob@^7.1.4