File tree 3 files changed +21
-0
lines changed
3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ function NYC (config) {
58
58
cwd : this . cwd ,
59
59
include : config . include ,
60
60
exclude : config . exclude ,
61
+ excludeNodeModules : config . excludeNodeModules !== false ,
61
62
extension : this . extensions
62
63
} )
63
64
Original file line number Diff line number Diff line change @@ -89,6 +89,12 @@ Config.buildYargs = function (cwd) {
89
89
description : 'should exclude logic be performed after the source-map remaps filenames?' ,
90
90
global : false
91
91
} )
92
+ . option ( 'exclude-node-modules' , {
93
+ default : true ,
94
+ type : 'boolean' ,
95
+ describe : 'whether or not to exclude all node_module folders (i.e. **/node_modules/**) by default' ,
96
+ global : false
97
+ } )
92
98
. option ( 'include' , {
93
99
alias : 'n' ,
94
100
default : [ ] ,
Original file line number Diff line number Diff line change @@ -123,6 +123,20 @@ describe('nyc', function () {
123
123
nyc . exclude . shouldInstrument ( '/cwd/foo/bar/__tests__/foo.js' , './__tests__/foo.js' ) . should . equal ( false )
124
124
} )
125
125
126
+ it ( 'should allow turning off default node_modules exclude' , function ( ) {
127
+ var nyc = new NYC ( configUtil . buildYargs ( '/cwd' ) . parse ( [
128
+ '--exclude-node-modules' , 'false' ,
129
+ '--exclude=**/__tests__/**' ,
130
+ '--exclude=node_modules/**'
131
+ ] ) )
132
+ // For this test, only excluding root node_modules. Local node_modules are allowed, but we
133
+ // still exclude matching items inside of local node_modules.
134
+ nyc . exclude . shouldInstrument ( '/cwd/foo' , 'foo' ) . should . equal ( true )
135
+ nyc . exclude . shouldInstrument ( '/cwd/node_modules/bar' , 'node_modules/bar' ) . should . equal ( false )
136
+ nyc . exclude . shouldInstrument ( '/cwd/foo/node_modules/bar' , 'foo/node_modules/bar' ) . should . equal ( true )
137
+ nyc . exclude . shouldInstrument ( '/cwd/foo/node_modules/bar/__tests__/baz.js' , 'foo/node_modules/bar/__tests__/baz.js' ) . should . equal ( false )
138
+ } )
139
+
126
140
it ( 'should exclude appropriately with config.exclude' , function ( ) {
127
141
var nyc = new NYC ( configUtil . buildYargs ( fixtures ) . parse ( ) )
128
142
You can’t perform that action at this time.
0 commit comments