From 658dba4ebbf8062e49965a77fb7df3f79a20c193 Mon Sep 17 00:00:00 2001 From: Jeff Principe Date: Mon, 4 Sep 2017 17:27:10 -0700 Subject: [PATCH] fix: remove excluded files from coverage before writing (#649) --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index 0933fa15f..f9b38c5e9 100755 --- a/index.js +++ b/index.js @@ -367,6 +367,13 @@ NYC.prototype.writeCoverageFile = function () { var coverage = coverageFinder() if (!coverage) return + // Remove any files that should be excluded but snuck into the coverage + Object.keys(coverage).forEach(function (absFile) { + if (!this.exclude.shouldInstrument(absFile)) { + delete coverage[absFile] + } + }, this) + if (this.cache) { Object.keys(coverage).forEach(function (absFile) { if (this.hashCache[absFile] && coverage[absFile]) {