Skip to content

Commit d616ffc

Browse files
authored
feat: upgrade to new test-exclude; with suppport for node_modules, and empty exclude (#348)
BREAKING CHANGE: node_modules is no longer automatically excluded, and an empty array of exclude rules can now be provided.
1 parent a82cf49 commit d616ffc

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

bin/nyc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ try {
1010
var processArgs = require('../lib/process-args')
1111

1212
var sw = require('spawn-wrap')
13+
var testExclude = require('test-exclude')
1314
var wrapper = require.resolve('./wrap.js')
1415
var Yargs = require('yargs/yargs')
1516

@@ -183,7 +184,7 @@ function buildYargs () {
183184
})
184185
.option('exclude', {
185186
alias: 'x',
186-
default: [],
187+
default: testExclude.defaultExclude,
187188
describe: 'a list of specific files and directories that should be excluded from coverage, glob patterns are supported, node_modules is always excluded'
188189
})
189190
.option('include', {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"rimraf": "^2.5.4",
9595
"signal-exit": "^3.0.0",
9696
"spawn-wrap": "^1.2.4",
97-
"test-exclude": "^1.1.0",
97+
"test-exclude": "^2.1.1",
9898
"yargs": "^4.8.1",
9999
"yargs-parser": "^3.1.0"
100100
},

test/src/nyc-test.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('nyc', function () {
6969
cwd: path.resolve(__dirname, '../fixtures')
7070
})
7171

72-
nyc.exclude.exclude.length.should.eql(5)
72+
nyc.exclude.exclude.length.should.eql(4)
7373
})
7474

7575
it("loads 'extension' patterns from package.json#nyc", function () {
@@ -95,19 +95,21 @@ describe('nyc', function () {
9595
nyc2.exclude.include.should.equal(false)
9696
})
9797

98-
it("ignores 'exclude' option if it's falsy or []", function () {
98+
it("ignores 'exclude' option if it's falsy", function () {
9999
var nyc1 = new NYC({
100100
cwd: path.resolve(__dirname, '../fixtures/conf-empty')
101101
})
102102

103103
nyc1.exclude.exclude.length.should.eql(7)
104+
})
104105

106+
it("allows for empty 'exclude'", function () {
105107
var nyc2 = new NYC({
106108
cwd: path.resolve(__dirname, '../fixtures/conf-empty'),
107109
exclude: []
108110
})
109111

110-
nyc2.exclude.exclude.length.should.eql(7)
112+
nyc2.exclude.exclude.length.should.eql(0)
111113
})
112114
})
113115

0 commit comments

Comments
 (0)