@@ -421,13 +421,13 @@ function coverageFinder () {
421
421
return coverage
422
422
}
423
423
424
- NYC . prototype . _getCoverageMapFromAllCoverageFiles = function ( ) {
424
+ NYC . prototype . getCoverageMapFromAllCoverageFiles = function ( baseDirectory ) {
425
425
var _this = this
426
426
var map = libCoverage . createCoverageMap ( { } )
427
427
428
- this . eachReport ( function ( report ) {
428
+ this . eachReport ( undefined , ( report ) => {
429
429
map . merge ( report )
430
- } )
430
+ } , baseDirectory )
431
431
// depending on whether source-code is pre-instrumented
432
432
// or instrumented using a JIT plugin like babel-require
433
433
// you may opt to exclude files after applying
@@ -443,7 +443,7 @@ NYC.prototype._getCoverageMapFromAllCoverageFiles = function () {
443
443
444
444
NYC . prototype . report = function ( ) {
445
445
var tree
446
- var map = this . _getCoverageMapFromAllCoverageFiles ( )
446
+ var map = this . getCoverageMapFromAllCoverageFiles ( )
447
447
var context = libReport . createContext ( {
448
448
dir : this . reportDirectory ( ) ,
449
449
watermarks : this . config . watermarks
@@ -469,7 +469,7 @@ NYC.prototype.showProcessTree = function () {
469
469
}
470
470
471
471
NYC . prototype . checkCoverage = function ( thresholds , perFile ) {
472
- var map = this . _getCoverageMapFromAllCoverageFiles ( )
472
+ var map = this . getCoverageMapFromAllCoverageFiles ( )
473
473
var nyc = this
474
474
475
475
if ( perFile ) {
@@ -516,20 +516,22 @@ NYC.prototype._loadProcessInfos = function () {
516
516
} )
517
517
}
518
518
519
- NYC . prototype . eachReport = function ( filenames , iterator ) {
519
+ NYC . prototype . eachReport = function ( filenames , iterator , baseDirectory ) {
520
+ baseDirectory = baseDirectory || this . tempDirectory ( )
521
+
520
522
if ( typeof filenames === 'function' ) {
521
523
iterator = filenames
522
524
filenames = undefined
523
525
}
524
526
525
527
var _this = this
526
- var files = filenames || fs . readdirSync ( this . tempDirectory ( ) )
528
+ var files = filenames || fs . readdirSync ( baseDirectory )
527
529
528
530
files . forEach ( function ( f ) {
529
531
var report
530
532
try {
531
533
report = JSON . parse ( fs . readFileSync (
532
- path . resolve ( _this . tempDirectory ( ) , f ) ,
534
+ path . resolve ( baseDirectory , f ) ,
533
535
'utf-8'
534
536
) )
535
537
@@ -545,7 +547,7 @@ NYC.prototype.eachReport = function (filenames, iterator) {
545
547
NYC . prototype . loadReports = function ( filenames ) {
546
548
var reports = [ ]
547
549
548
- this . eachReport ( filenames , function ( report ) {
550
+ this . eachReport ( filenames , ( report ) => {
549
551
reports . push ( report )
550
552
} )
551
553
0 commit comments