@@ -11,17 +11,16 @@ const glob = require('glob')
11
11
const Hash = require ( './lib/hash' )
12
12
const libCoverage = require ( 'istanbul-lib-coverage' )
13
13
const libHook = require ( 'istanbul-lib-hook' )
14
- const libReport = require ( 'istanbul-lib-report' )
15
14
const mkdirp = require ( 'make-dir' )
16
15
const Module = require ( 'module' )
17
16
const onExit = require ( 'signal-exit' )
18
17
const path = require ( 'path' )
19
- const reports = require ( 'istanbul-reports' )
20
18
const resolveFrom = require ( 'resolve-from' )
21
19
const rimraf = require ( 'rimraf' )
22
20
const SourceMaps = require ( './lib/source-maps' )
23
21
const testExclude = require ( 'test-exclude' )
24
22
const uuid = require ( 'uuid/v4' )
23
+ const api = require ( 'istanbul-api' )
25
24
26
25
const debugLog = util . debuglog ( 'nyc' )
27
26
@@ -90,6 +89,12 @@ function NYC (config) {
90
89
this . rootId = this . processInfo . root || this . generateUniqueID ( )
91
90
92
91
this . hashCache = { }
92
+
93
+ this . config . reporting = config . reporting || { }
94
+ this . config . reporting [ 'dir' ] = this . reportDirectory ( )
95
+ this . config . reporting [ 'report-config' ] = this . _reportConfig ( )
96
+ this . config . reporting [ 'summarizer' ] = this . _reportSummarizer ( )
97
+ this . config . reporting [ 'watermarks' ] = this . _reportWatermarks ( )
93
98
}
94
99
95
100
NYC . prototype . _createTransform = function ( ext ) {
@@ -441,21 +446,12 @@ NYC.prototype.getCoverageMapFromAllCoverageFiles = function (baseDirectory) {
441
446
}
442
447
443
448
NYC . prototype . report = function ( ) {
444
- var tree
445
- var map = this . getCoverageMapFromAllCoverageFiles ( )
446
- var context = libReport . createContext ( {
447
- dir : this . reportDirectory ( ) ,
448
- watermarks : this . config . watermarks
449
- } )
449
+ const config = api . config . loadObject ( this . config )
450
+ const reporter = api . createReporter ( config )
451
+ const map = this . getCoverageMapFromAllCoverageFiles ( )
450
452
451
- tree = libReport . summarizers . pkg ( map )
452
-
453
- this . reporter . forEach ( ( _reporter ) => {
454
- tree . visit ( reports . create ( _reporter , {
455
- skipEmpty : this . config . skipEmpty ,
456
- skipFull : this . config . skipFull
457
- } ) , context )
458
- } )
453
+ reporter . addAll ( this . reporter )
454
+ reporter . write ( map )
459
455
460
456
if ( this . _showProcessTree ) {
461
457
this . showProcessTree ( )
@@ -566,4 +562,25 @@ NYC.prototype.processInfoDirectory = function () {
566
562
return path . resolve ( this . tempDirectory ( ) , 'processinfo' )
567
563
}
568
564
565
+ NYC . prototype . _reportConfig = function ( ) {
566
+ const config = { }
567
+
568
+ this . reporter . forEach ( _reporter => {
569
+ config [ _reporter ] = {
570
+ skipEmpty : this . config . skipEmpty ,
571
+ skipFull : this . config . skipFull
572
+ }
573
+ } )
574
+
575
+ return config
576
+ }
577
+
578
+ NYC . prototype . _reportSummarizer = function ( ) {
579
+ return 'pkg'
580
+ }
581
+
582
+ NYC . prototype . _reportWatermarks = function ( ) {
583
+ return this . config . watermarks
584
+ }
585
+
569
586
module . exports = NYC
0 commit comments