Skip to content

Commit 2828538

Browse files
authored
feat: node_modules is again excluded by default when custom exclude is provided (#442)
BREAKING CHANGE: **/node_modules/** is again excluded by default.
1 parent 31488f5 commit 2828538

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ and anything in the `build` directory:
191191
}
192192
}
193193
```
194-
> Note: Since version 8.0 if you add a "exclude" array the `node_modules`
195-
folder is not automatically excluded, you will need to explicitly add it to your exclude array
194+
> Note: Since version 9.0 files under `node_modules/` are excluded by default.
195+
add the exclude rule `!**/node_modules/` to stop this.
196196

197-
> Note: exclude defaults to `['test', 'test{,-*}.js', '**/*.test.js', '**/__tests__/**']`,
197+
> Note: exclude defaults to `['test', 'test{,-*}.js', '**/*.test.js', '**/__tests__/**', '**/node_modules/**']`,
198198
which would exclude `test`/`__tests__` directories as well as `test.js`, `*.test.js`,
199199
and `test-*.js` files. Specifying your own exclude property overrides these defaults.
200200

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@
8383
"glob": "^7.0.6",
8484
"istanbul-lib-coverage": "^1.0.0",
8585
"istanbul-lib-hook": "^1.0.0-alpha.4",
86-
"istanbul-lib-instrument": "^1.2.0",
86+
"istanbul-lib-instrument": "^1.3.0",
8787
"istanbul-lib-report": "^1.0.0-alpha.3",
88-
"istanbul-lib-source-maps": "^1.0.2",
88+
"istanbul-lib-source-maps": "^1.1.0",
8989
"istanbul-reports": "^1.0.0",
9090
"md5-hex": "^1.2.0",
9191
"merge-source-map": "^1.0.2",
@@ -95,7 +95,7 @@
9595
"rimraf": "^2.5.4",
9696
"signal-exit": "^3.0.1",
9797
"spawn-wrap": "^1.2.4",
98-
"test-exclude": "^2.1.3",
98+
"test-exclude": "^3.0.0",
9999
"yargs": "^6.0.0",
100100
"yargs-parser": "^4.0.2"
101101
},
@@ -157,4 +157,4 @@
157157
"find-up"
158158
]
159159
}
160-
}
160+
}

test/src/nyc-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('nyc', function () {
6666
describe('config', function () {
6767
it("loads 'exclude' patterns from package.json#nyc", function () {
6868
var nyc = new NYC(configUtil.loadConfig([], path.resolve(__dirname, '../fixtures')))
69-
nyc.exclude.exclude.length.should.eql(4)
69+
nyc.exclude.exclude.length.should.eql(5)
7070
})
7171

7272
it("loads 'extension' patterns from package.json#nyc", function () {
@@ -97,14 +97,14 @@ describe('nyc', function () {
9797
it("allows for empty 'exclude'", function () {
9898
var nyc2 = new NYC({exclude: []})
9999

100-
nyc2.exclude.exclude.length.should.eql(0)
100+
// an empty exclude still has !**/node_modules/** added.
101+
nyc2.exclude.exclude.length.should.eql(1)
101102
})
102103
})
103104

104105
describe('shouldInstrumentFile', function () {
105106
it('should exclude appropriately with defaults', function () {
106107
var nyc = new NYC(configUtil.loadConfig([
107-
'--exclude=**/node_modules/**',
108108
'--exclude=test/**',
109109
'--exclude=test{,-*}.js',
110110
'--exclude=**/*.test.js',

0 commit comments

Comments
 (0)