diff --git a/index.js b/index.js index 80198b2c3..46c6d60c2 100755 --- a/index.js +++ b/index.js @@ -11,16 +11,17 @@ 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') @@ -83,12 +84,6 @@ 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) { @@ -440,12 +435,21 @@ NYC.prototype.getCoverageMapFromAllCoverageFiles = function (baseDirectory) { } NYC.prototype.report = function () { - const config = api.config.loadObject(this.config) - const reporter = api.createReporter(config) - const map = this.getCoverageMapFromAllCoverageFiles() + var tree + var map = this.getCoverageMapFromAllCoverageFiles() + var context = libReport.createContext({ + dir: this.reportDirectory(), + watermarks: this.config.watermarks + }) - reporter.addAll(this.reporter) - reporter.write(map) + tree = libReport.summarizers.pkg(map) + + this.reporter.forEach((_reporter) => { + tree.visit(reports.create(_reporter, { + skipEmpty: this.config.skipEmpty, + skipFull: this.config.skipFull + }), context) + }) if (this._showProcessTree) { this.showProcessTree() @@ -553,25 +557,4 @@ 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 diff --git a/package-lock.json b/package-lock.json index 175be854e..5f3f526aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -189,6 +189,7 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, "requires": { "sprintf-js": "~1.0.2" } @@ -946,11 +947,6 @@ "dot-prop": "^3.0.0" } }, - "compare-versions": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.4.0.tgz", - "integrity": "sha512-tK69D7oNXXqUW3ZNo/z7NXTEz22TCF0pTE+YF9cxvaAM9XnkLo1fV621xCLrRR6aevJlKxExkss0vWqUCUpqdg==" - }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2172,7 +2168,8 @@ "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true }, "esquery": { "version": "1.0.1", @@ -2297,15 +2294,6 @@ "object-assign": "^4.0.1" } }, - "fileset": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/fileset/-/fileset-2.0.3.tgz", - "integrity": "sha1-jnVIqW08wjJ+5eZ0FocjozO7oqA=", - "requires": { - "glob": "^7.0.3", - "minimatch": "^3.0.3" - } - }, "find-cache-dir": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.0.0.tgz", @@ -3003,26 +2991,6 @@ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, - "istanbul-api": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/istanbul-api/-/istanbul-api-2.1.1.tgz", - "integrity": "sha512-kVmYrehiwyeBAk/wE71tW6emzLiHGjYIiDrc8sfyty4F8M02/lrgXSm+R1kXysmF20zArvmZXjlE/mg24TVPJw==", - "requires": { - "async": "^2.6.1", - "compare-versions": "^3.2.1", - "fileset": "^2.0.3", - "istanbul-lib-coverage": "^2.0.3", - "istanbul-lib-hook": "^2.0.3", - "istanbul-lib-instrument": "^3.1.0", - "istanbul-lib-report": "^2.0.4", - "istanbul-lib-source-maps": "^3.0.2", - "istanbul-reports": "^2.1.1", - "js-yaml": "^3.12.0", - "make-dir": "^1.3.0", - "minimatch": "^3.0.4", - "once": "^1.4.0" - } - }, "istanbul-lib-coverage": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", @@ -3106,6 +3074,7 @@ "version": "3.12.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.1.tgz", "integrity": "sha512-um46hB9wNOKlwkHgiuyEVAybXBjwFUV0Z/RaHJblRd9DXltue9FTYvzCr9ErQrK9Adz5MU4gHWVaNUfdmrC8qA==", + "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -5338,7 +5307,8 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true }, "sshpk": { "version": "1.16.1", diff --git a/package.json b/package.json index cb85361d5..71c4fbc27 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,6 @@ "find-up": "^3.0.0", "foreground-child": "^1.5.6", "glob": "^7.1.3", - "istanbul-api": "^2.1.0", "istanbul-lib-coverage": "^2.0.3", "istanbul-lib-hook": "^2.0.3", "istanbul-lib-instrument": "^3.1.0",