@@ -11,17 +11,16 @@ 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' )
1514const mkdirp = require ( 'make-dir' )
1615const Module = require ( 'module' )
1716const onExit = require ( 'signal-exit' )
1817const path = require ( 'path' )
19- const reports = require ( 'istanbul-reports' )
2018const resolveFrom = require ( 'resolve-from' )
2119const rimraf = require ( 'rimraf' )
2220const SourceMaps = require ( './lib/source-maps' )
2321const testExclude = require ( 'test-exclude' )
2422const uuid = require ( 'uuid/v4' )
23+ const api = require ( 'istanbul-api' )
2524
2625const debugLog = util . debuglog ( 'nyc' )
2726
@@ -90,6 +89,12 @@ function NYC (config) {
9089 this . rootId = this . processInfo . root || this . generateUniqueID ( )
9190
9291 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 ( )
9398}
9499
95100NYC . prototype . _createTransform = function ( ext ) {
@@ -441,21 +446,12 @@ NYC.prototype.getCoverageMapFromAllCoverageFiles = function (baseDirectory) {
441446}
442447
443448NYC . 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 ( )
450452
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 )
459455
460456 if ( this . _showProcessTree ) {
461457 this . showProcessTree ( )
@@ -566,4 +562,25 @@ NYC.prototype.processInfoDirectory = function () {
566562 return path . resolve ( this . tempDirectory ( ) , 'processinfo' )
567563}
568564
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+
569586module . exports = NYC
0 commit comments