Skip to content
Permalink
Browse files

feat: add support to exclude files on coverage report generation (#982)

  • Loading branch information
henriquemotaesteves authored and JaKXz committed Feb 20, 2019
1 parent 12b8986 commit 509c6aae5e001f45ad284901ada141dca6a3a2f4
Showing with 109 additions and 53 deletions.
  1. +33 −16 index.js
  2. +75 −37 package-lock.json
  3. +1 −0 package.json
@@ -11,17 +11,16 @@ const glob = require('glob')
const Hash = require('./lib/hash')
const libCoverage = require('istanbul-lib-coverage')
const libHook = require('istanbul-lib-hook')
const libReport = require('istanbul-lib-report')
const mkdirp = require('make-dir')
const Module = require('module')
const onExit = require('signal-exit')
const path = require('path')
const reports = require('istanbul-reports')
const resolveFrom = require('resolve-from')
const rimraf = require('rimraf')
const SourceMaps = require('./lib/source-maps')
const testExclude = require('test-exclude')
const uuid = require('uuid/v4')
const api = require('istanbul-api')

const debugLog = util.debuglog('nyc')

@@ -90,6 +89,12 @@ function NYC (config) {
this.rootId = this.processInfo.root || this.generateUniqueID()

this.hashCache = {}

this.config.reporting = config.reporting || {}
this.config.reporting['dir'] = this.reportDirectory()
this.config.reporting['report-config'] = this._reportConfig()
this.config.reporting['summarizer'] = this._reportSummarizer()
this.config.reporting['watermarks'] = this._reportWatermarks()
}

NYC.prototype._createTransform = function (ext) {
@@ -441,21 +446,12 @@ NYC.prototype.getCoverageMapFromAllCoverageFiles = function (baseDirectory) {
}

NYC.prototype.report = function () {
var tree
var map = this.getCoverageMapFromAllCoverageFiles()
var context = libReport.createContext({
dir: this.reportDirectory(),
watermarks: this.config.watermarks
})
const config = api.config.loadObject(this.config)
const reporter = api.createReporter(config)
const map = this.getCoverageMapFromAllCoverageFiles()

tree = libReport.summarizers.pkg(map)

this.reporter.forEach((_reporter) => {
tree.visit(reports.create(_reporter, {
skipEmpty: this.config.skipEmpty,
skipFull: this.config.skipFull
}), context)
})
reporter.addAll(this.reporter)
reporter.write(map)

if (this._showProcessTree) {
this.showProcessTree()
@@ -566,4 +562,25 @@ NYC.prototype.processInfoDirectory = function () {
return path.resolve(this.tempDirectory(), 'processinfo')
}

NYC.prototype._reportConfig = function () {
const config = {}

this.reporter.forEach(_reporter => {
config[_reporter] = {
skipEmpty: this.config.skipEmpty,
skipFull: this.config.skipFull
}
})

return config
}

NYC.prototype._reportSummarizer = function () {
return 'pkg'
}

NYC.prototype._reportWatermarks = function () {
return this.config.watermarks
}

module.exports = NYC

0 comments on commit 509c6aa

Please sign in to comment.
You can’t perform that action at this time.