c8 7.7.1 → 7.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/lib/report.js +23 -6
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [7.7.2](https://www.github.com/bcoe/c8/compare/v7.7.1...v7.7.2) (2021-05-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* address bugs with source remapping on Windows ([#301](https://www.github.com/bcoe/c8/issues/301)) ([c817902](https://www.github.com/bcoe/c8/commit/c81790262f843c01b3d14390fde81dbdbcf2226f))
|
|
11
|
+
|
|
5
12
|
### [7.7.1](https://www.github.com/bcoe/c8/compare/v7.7.0...v7.7.1) (2021-04-07)
|
|
6
13
|
|
|
7
14
|
|
package/lib/report.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const Exclude = require('test-exclude')
|
|
2
|
-
const furi = require('furi')
|
|
3
2
|
const libCoverage = require('istanbul-lib-coverage')
|
|
4
3
|
const libReport = require('istanbul-lib-report')
|
|
5
4
|
const reports = require('istanbul-reports')
|
|
6
5
|
const { readdirSync, readFileSync, statSync } = require('fs')
|
|
7
6
|
const { isAbsolute, resolve, extname } = require('path')
|
|
7
|
+
const { pathToFileURL, fileURLToPath } = require('url')
|
|
8
8
|
const getSourceMapFromFile = require('./source-map-from-file')
|
|
9
9
|
// TODO: switch back to @c88/v8-coverage once patch is landed.
|
|
10
10
|
const v8toIstanbul = require('v8-to-istanbul')
|
|
@@ -139,8 +139,8 @@ class Report {
|
|
|
139
139
|
*/
|
|
140
140
|
_getSourceMap (v8ScriptCov) {
|
|
141
141
|
const sources = {}
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
const sourceMapAndLineLengths = this.sourceMapCache[pathToFileURL(v8ScriptCov.url).href]
|
|
143
|
+
if (sourceMapAndLineLengths) {
|
|
144
144
|
// See: https://github.com/nodejs/node/pull/34305
|
|
145
145
|
if (!sourceMapAndLineLengths.data) return
|
|
146
146
|
sources.sourceMap = {
|
|
@@ -173,7 +173,7 @@ class Report {
|
|
|
173
173
|
for (const v8ProcessCov of this._loadReports()) {
|
|
174
174
|
if (this._isCoverageObject(v8ProcessCov)) {
|
|
175
175
|
if (v8ProcessCov['source-map-cache']) {
|
|
176
|
-
Object.assign(this.sourceMapCache, v8ProcessCov['source-map-cache'])
|
|
176
|
+
Object.assign(this.sourceMapCache, this._normalizeSourceMapCache(v8ProcessCov['source-map-cache']))
|
|
177
177
|
}
|
|
178
178
|
v8ProcessCovs.push(this._normalizeProcessCov(v8ProcessCov, fileIndex))
|
|
179
179
|
}
|
|
@@ -194,7 +194,7 @@ class Report {
|
|
|
194
194
|
const stat = statSync(fullPath)
|
|
195
195
|
const sourceMap = getSourceMapFromFile(fullPath)
|
|
196
196
|
if (sourceMap) {
|
|
197
|
-
this.sourceMapCache[
|
|
197
|
+
this.sourceMapCache[pathToFileURL(fullPath)] = { data: sourceMap }
|
|
198
198
|
}
|
|
199
199
|
emptyReports.push({
|
|
200
200
|
scriptId: 0,
|
|
@@ -275,7 +275,7 @@ class Report {
|
|
|
275
275
|
}
|
|
276
276
|
if (/^file:\/\//.test(v8ScriptCov.url)) {
|
|
277
277
|
try {
|
|
278
|
-
v8ScriptCov.url =
|
|
278
|
+
v8ScriptCov.url = fileURLToPath(v8ScriptCov.url)
|
|
279
279
|
fileIndex.add(v8ScriptCov.url)
|
|
280
280
|
} catch (err) {
|
|
281
281
|
debuglog(`${err.stack}`)
|
|
@@ -290,6 +290,23 @@ class Report {
|
|
|
290
290
|
}
|
|
291
291
|
return { result }
|
|
292
292
|
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Normalizes a V8 source map cache.
|
|
296
|
+
*
|
|
297
|
+
* This function normalizes file URLs to a system-independent format.
|
|
298
|
+
*
|
|
299
|
+
* @param v8SourceMapCache V8 source map cache to normalize.
|
|
300
|
+
* @return {v8SourceMapCache} Normalized V8 source map cache.
|
|
301
|
+
* @private
|
|
302
|
+
*/
|
|
303
|
+
_normalizeSourceMapCache (v8SourceMapCache) {
|
|
304
|
+
const cache = {}
|
|
305
|
+
for (const fileURL of Object.keys(v8SourceMapCache)) {
|
|
306
|
+
cache[pathToFileURL(fileURLToPath(fileURL)).href] = v8SourceMapCache[fileURL]
|
|
307
|
+
}
|
|
308
|
+
return cache
|
|
309
|
+
}
|
|
293
310
|
}
|
|
294
311
|
|
|
295
312
|
module.exports = function (opts) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c8",
|
|
3
|
-
"version": "7.7.
|
|
3
|
+
"version": "7.7.2",
|
|
4
4
|
"description": "output coverage reports using Node.js' built in coverage",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"@istanbuljs/schema": "^0.1.2",
|
|
38
38
|
"find-up": "^5.0.0",
|
|
39
39
|
"foreground-child": "^2.0.0",
|
|
40
|
-
"furi": "^2.0.0",
|
|
41
40
|
"istanbul-lib-coverage": "^3.0.0",
|
|
42
41
|
"istanbul-lib-report": "^3.0.0",
|
|
43
42
|
"istanbul-reports": "^3.0.2",
|