File tree 5 files changed +51
-2
lines changed
5 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -451,8 +451,10 @@ NYC.prototype.report = function () {
451
451
452
452
tree = libReport . summarizers . pkg ( map )
453
453
454
- this . reporter . forEach ( function ( _reporter ) {
455
- tree . visit ( reports . create ( _reporter ) , context )
454
+ this . reporter . forEach ( ( _reporter ) => {
455
+ tree . visit ( reports . create ( _reporter , {
456
+ skipEmpty : this . config . skipEmpty
457
+ } ) , context )
456
458
} )
457
459
458
460
if ( this . _showProcessTree ) {
Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ exports.builder = function (yargs) {
29
29
default : false ,
30
30
type : 'boolean'
31
31
} )
32
+ . option ( 'skip-empty' , {
33
+ describe : 'don\'t show empty files (no lines of code) in report' ,
34
+ default : false ,
35
+ type : 'boolean' ,
36
+ global : false
37
+ } )
32
38
. example ( '$0 report --reporter=lcov' , 'output an HTML lcov report to ./coverage' )
33
39
}
34
40
Original file line number Diff line number Diff line change @@ -215,6 +215,12 @@ Config.buildYargs = function (cwd) {
215
215
default : './.nyc_output' ,
216
216
global : false
217
217
} )
218
+ . option ( 'skip-empty' , {
219
+ describe : 'don\'t show empty files (no lines of code) in report' ,
220
+ default : false ,
221
+ type : 'boolean' ,
222
+ global : false
223
+ } )
218
224
. pkgConf ( 'nyc' , cwd )
219
225
. example ( '$0 npm test' , 'instrument your tests with coverage' )
220
226
. example ( '$0 --require babel-core/register npm test' , 'instrument your tests with coverage and transpile with Babel' )
Original file line number Diff line number Diff line change @@ -937,6 +937,41 @@ describe('the nyc cli', function () {
937
937
} )
938
938
} )
939
939
} )
940
+
941
+ describe ( 'skip-empty' , ( ) => {
942
+ it ( 'does not display 0-line files in coverage output' , ( done ) => {
943
+ const args = [
944
+ bin ,
945
+ '--cache' , 'false' ,
946
+ '--skip-empty' , 'true' ,
947
+ process . execPath , './empty.js'
948
+ ]
949
+
950
+ const proc = spawn ( process . execPath , args , {
951
+ cwd : fixturesCLI ,
952
+ env : env
953
+ } )
954
+
955
+ var stdout = ''
956
+ proc . stdout . on ( 'data' , function ( chunk ) {
957
+ stdout += chunk
958
+ } )
959
+
960
+ proc . stdout . on ( 'error' , function ( chunk ) {
961
+ stdout += chunk
962
+ } )
963
+
964
+ proc . on ( 'close' , function ( code ) {
965
+ code . should . equal ( 0 )
966
+ stdoutShouldEqual ( stdout , `
967
+ ----------|----------|----------|----------|----------|-------------------|
968
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
969
+ ----------|----------|----------|----------|----------|-------------------|
970
+ ----------|----------|----------|----------|----------|-------------------|` )
971
+ done ( )
972
+ } )
973
+ } )
974
+ } )
940
975
} )
941
976
942
977
function stdoutShouldEqual ( stdout , expected ) {
You can’t perform that action at this time.
0 commit comments