c8 7.11.1 → 7.12.0
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/README.md +19 -0
- package/lib/report.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ Here is a list of common options. Run `c8 --help` for the full list and document
|
|
|
36
36
|
| `--src` | see [section below](#checking-for-full-source-coverage-using---all) for more info | `Array<string>` | `[process.cwd()]`|
|
|
37
37
|
| `-n`, `--include` | see [section below](#checking-for-full-source-coverage-using---all) for more info | `Array<string>` | `[]` (include all files) |
|
|
38
38
|
| `-x`, `--exclude` | see [section below](#checking-for-full-source-coverage-using---all) for more info | `Array<string>` | [list](https://github.com/istanbuljs/schema/blob/master/default-exclude.js) |
|
|
39
|
+
| `--exclude-after-remap` | see [section below](#exclude-after-remap) for more info | `boolean` | `false` |
|
|
39
40
|
| `-e`, `--extension` | only files matching these extensions will show coverage | `string \| Array<string>` | [list](https://github.com/istanbuljs/schema/blob/master/default-extension.js) |
|
|
40
41
|
| `--skip-full` | do not show files with 100% statement, branch, and function coverage | `boolean` | `false` |
|
|
41
42
|
| `--check-coverage` | check whether coverage is within thresholds provided | `boolean` | `false` |
|
|
@@ -53,6 +54,24 @@ By supplying `--all` to c8, all files in directories specified with `--src` (def
|
|
|
53
54
|
and `--exclude` flag checks, will be loaded into the report. If any of those files remain uncovered they will be factored
|
|
54
55
|
into the report with a default of 0% coverage.
|
|
55
56
|
|
|
57
|
+
## SourceMap Support
|
|
58
|
+
|
|
59
|
+
`c8` can handle source-maps, for remapping coverage from generated code to original source files (_useful for TypeScript, JSX, etc_).
|
|
60
|
+
|
|
61
|
+
### Source map files versus inline source maps
|
|
62
|
+
|
|
63
|
+
Just-in-time instrumented codebases will often insert source maps inline with the `.js` code they generate at runtime (e.g, `@babel/register` can be configured to insert a source map footer).
|
|
64
|
+
|
|
65
|
+
Pre-instrumented codebases, e.g., running `tsc` to generate `.js` in a build folder, may generate either inline source maps, or a separate `.map` file stored on disk.
|
|
66
|
+
|
|
67
|
+
`c8` can handle loading both types of source maps.
|
|
68
|
+
|
|
69
|
+
### Exclude after remap
|
|
70
|
+
|
|
71
|
+
Depending on the size and configuration of your project, it may be preferable to apply exclusion logic either before or after source-maps are used to remap compiled to original source files.
|
|
72
|
+
|
|
73
|
+
`--exclude-after-remap` is used to control this behaviour.
|
|
74
|
+
|
|
56
75
|
## c8 report
|
|
57
76
|
|
|
58
77
|
run `c8 report` to regenerate reports after `c8` has already been run.
|
package/lib/report.js
CHANGED
|
@@ -74,7 +74,7 @@ class Report {
|
|
|
74
74
|
reports.create(_reporter, {
|
|
75
75
|
skipEmpty: false,
|
|
76
76
|
skipFull: this.skipFull,
|
|
77
|
-
maxCols: 100
|
|
77
|
+
maxCols: process.stdout.columns || 100
|
|
78
78
|
}).execute(context)
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -190,12 +190,13 @@ class Report {
|
|
|
190
190
|
result: emptyReports
|
|
191
191
|
})
|
|
192
192
|
const workingDirs = this.src
|
|
193
|
+
const { extension } = this.exclude
|
|
193
194
|
for (const workingDir of workingDirs) {
|
|
194
195
|
this.exclude.globSync(workingDir).forEach((f) => {
|
|
195
196
|
const fullPath = resolve(workingDir, f)
|
|
196
197
|
if (!fileIndex.has(fullPath)) {
|
|
197
198
|
const ext = extname(fullPath)
|
|
198
|
-
if (
|
|
199
|
+
if (extension.includes(ext)) {
|
|
199
200
|
const stat = statSync(fullPath)
|
|
200
201
|
const sourceMap = getSourceMapFromFile(fullPath)
|
|
201
202
|
if (sourceMap) {
|