Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: simplify istanbul-lib-coverage API usage #369

Merged
merged 1 commit into from
Aug 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,17 +391,23 @@ function coverageFinder () {
return coverage
}

NYC.prototype.report = function () {
var tree
NYC.prototype._getCoverageMapFromAllCoverageFiles = function () {
var map = libCoverage.createCoverageMap({})
var context = libReport.createContext({
dir: this._reportDir
})

this._loadReports().forEach(function (report) {
map.merge(report)
})

return map
}

NYC.prototype.report = function () {
var tree
var map = this._getCoverageMapFromAllCoverageFiles()
var context = libReport.createContext({
dir: this._reportDir
})

tree = libReport.summarizers.pkg(map)

this.reporter.forEach(function (_reporter) {
Expand All @@ -410,22 +416,12 @@ NYC.prototype.report = function () {
}

NYC.prototype.checkCoverage = function (thresholds) {
var map = libCoverage.createCoverageMap({})
var summary = libCoverage.createCoverageSummary()

this._loadReports().forEach(function (report) {
map.merge(report)
})

map.files().forEach(function (f) {
var fc = map.fileCoverageFor(f)
var s = fc.toSummary()
summary.merge(s)
})
var map = this._getCoverageMapFromAllCoverageFiles()
var summary = map.getCoverageSummary()

// ERROR: Coverage for lines (90.12%) does not meet global threshold (120%)
Object.keys(thresholds).forEach(function (key) {
var coverage = summary.data[key].pct
var coverage = summary[key].pct
if (coverage < thresholds[key]) {
process.exitCode = 1
console.error('ERROR: Coverage for ' + key + ' (' + coverage + '%) does not meet global threshold (' + thresholds[key] + '%)')
Expand Down