Skip to content

Commit

Permalink
fix: Pull default settings from @istanbuljs/schema (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell committed Dec 5, 2019
1 parent 100331b commit ffca696
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 61 deletions.
13 changes: 0 additions & 13 deletions default-exclude.js

This file was deleted.

28 changes: 6 additions & 22 deletions index.js
Expand Up @@ -4,20 +4,15 @@ const path = require('path');
const { promisify } = require('util');
const glob = promisify(require('glob'));
const minimatch = require('minimatch');
const defaultExclude = require('./default-exclude');
const { defaults } = require('@istanbuljs/schema');
const isOutsideDir = require('./is-outside-dir');

class TestExclude {
constructor(opts) {
Object.assign(
this,
{
cwd: process.cwd(),
include: false,
relativePath: true,
excludeNodeModules: true,
extension: false
},
{relativePath: true},
defaults.testExclude,
opts
);

Expand All @@ -31,18 +26,11 @@ class TestExclude {

if (typeof this.extension === 'string') {
this.extension = [this.extension];
} else if (
!Array.isArray(this.extension) ||
this.extension.length === 0
) {
} else if (this.extension.length === 0) {
this.extension = false;
}

if (!this.exclude || !Array.isArray(this.exclude)) {
this.exclude = defaultExclude;
}

if (this.include && this.include.length > 0) {
if (this.include.length > 0) {
this.include = prepGlobPatterns([].concat(this.include));
} else {
this.include = false;
Expand Down Expand Up @@ -165,8 +153,4 @@ function getExtensionPattern(extension) {
}
}

const exportFunc = opts => new TestExclude(opts);

exportFunc.defaultExclude = defaultExclude;

module.exports = exportFunc;
module.exports = opts => new TestExclude(opts);
2 changes: 1 addition & 1 deletion nyc.config.js
@@ -1,6 +1,6 @@
'use strict';

const defaultExclude = require('./default-exclude');
const defaultExclude = require('@istanbuljs/schema/default-exclude.js');

const isWindows = process.platform === 'win32';

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -30,6 +30,7 @@
},
"homepage": "https://istanbul.js.org/",
"dependencies": {
"@istanbuljs/schema": "^0.1.2",
"glob": "^7.1.4",
"minimatch": "^3.0.4"
},
Expand Down
2 changes: 0 additions & 2 deletions tap-snapshots/test-glob.js-TAP.test.js
Expand Up @@ -42,10 +42,8 @@ Array [

exports[`test/glob.js TAP should exclude the node_modules folder by default > absolute constructor cwd 1`] = `
Array [
".nycrc",
"file1.js",
"file2.js",
"package.json",
]
`

Expand Down
18 changes: 0 additions & 18 deletions tap-snapshots/test-test-exclude.js-TAP.test.js

This file was deleted.

8 changes: 3 additions & 5 deletions test/test-exclude.js
Expand Up @@ -223,6 +223,9 @@ t.test(

t.test('no extension option', t =>
testHelper(t, {
options: {
extension: []
},
yes: ['file.js', 'package.json']
})
);
Expand Down Expand Up @@ -258,11 +261,6 @@ t.test(
})
);

t.test('exports defaultExclude', t => {
t.matchSnapshot(exclude.defaultExclude);
t.end();
});

// see: https://github.com/istanbuljs/babel-plugin-istanbul/issues/71
t.test('allows exclude/include rule to be a string', t =>
testHelper(t, {
Expand Down

0 comments on commit ffca696

Please sign in to comment.