@@ -11,16 +11,17 @@ const glob = require('glob')
1111const Hash = require ( './lib/hash' )
1212const libCoverage = require ( 'istanbul-lib-coverage' )
1313const libHook = require ( 'istanbul-lib-hook' )
14+ const libReport = require ( 'istanbul-lib-report' )
1415const mkdirp = require ( 'make-dir' )
1516const Module = require ( 'module' )
1617const onExit = require ( 'signal-exit' )
1718const path = require ( 'path' )
19+ const reports = require ( 'istanbul-reports' )
1820const resolveFrom = require ( 'resolve-from' )
1921const rimraf = require ( 'rimraf' )
2022const SourceMaps = require ( './lib/source-maps' )
2123const testExclude = require ( 'test-exclude' )
2224const uuid = require ( 'uuid/v4' )
23- const api = require ( 'istanbul-api' )
2425
2526const debugLog = util . debuglog ( 'nyc' )
2627
@@ -83,12 +84,6 @@ function NYC (config) {
8384 this . rootId = this . processInfo . root || this . generateUniqueID ( )
8485
8586 this . hashCache = { }
86-
87- this . config . reporting = config . reporting || { }
88- this . config . reporting [ 'dir' ] = this . reportDirectory ( )
89- this . config . reporting [ 'report-config' ] = this . _reportConfig ( )
90- this . config . reporting [ 'summarizer' ] = this . _reportSummarizer ( )
91- this . config . reporting [ 'watermarks' ] = this . _reportWatermarks ( )
9287}
9388
9489NYC . prototype . _createTransform = function ( ext ) {
@@ -440,12 +435,21 @@ NYC.prototype.getCoverageMapFromAllCoverageFiles = function (baseDirectory) {
440435}
441436
442437NYC . prototype . report = function ( ) {
443- const config = api . config . loadObject ( this . config )
444- const reporter = api . createReporter ( config )
445- const map = this . getCoverageMapFromAllCoverageFiles ( )
438+ var tree
439+ var map = this . getCoverageMapFromAllCoverageFiles ( )
440+ var context = libReport . createContext ( {
441+ dir : this . reportDirectory ( ) ,
442+ watermarks : this . config . watermarks
443+ } )
446444
447- reporter . addAll ( this . reporter )
448- reporter . write ( map )
445+ tree = libReport . summarizers . pkg ( map )
446+
447+ this . reporter . forEach ( ( _reporter ) => {
448+ tree . visit ( reports . create ( _reporter , {
449+ skipEmpty : this . config . skipEmpty ,
450+ skipFull : this . config . skipFull
451+ } ) , context )
452+ } )
449453
450454 if ( this . _showProcessTree ) {
451455 this . showProcessTree ( )
@@ -553,25 +557,4 @@ NYC.prototype.processInfoDirectory = function () {
553557 return path . resolve ( this . tempDirectory ( ) , 'processinfo' )
554558}
555559
556- NYC . prototype . _reportConfig = function ( ) {
557- const config = { }
558-
559- this . reporter . forEach ( _reporter => {
560- config [ _reporter ] = {
561- skipEmpty : this . config . skipEmpty ,
562- skipFull : this . config . skipFull
563- }
564- } )
565-
566- return config
567- }
568-
569- NYC . prototype . _reportSummarizer = function ( ) {
570- return 'pkg'
571- }
572-
573- NYC . prototype . _reportWatermarks = function ( ) {
574- return this . config . watermarks
575- }
576-
577560module . exports = NYC
0 commit comments