c8 7.9.0 → 7.10.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/CHANGELOG.md +7 -0
- package/README.md +19 -1
- package/lib/commands/check-coverage.js +8 -0
- package/lib/commands/report.js +8 -0
- package/lib/parse-args.js +19 -0
- package/package.json +2 -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.10.0](https://www.github.com/bcoe/c8/compare/v7.9.0...v7.10.0) (2021-10-06)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* `--100` ([#332](https://www.github.com/bcoe/c8/issues/332)) ([4205f2f](https://www.github.com/bcoe/c8/commit/4205f2f33585693d82c2500d0d6850571965bb8b))
|
|
11
|
+
|
|
5
12
|
## [7.9.0](https://www.github.com/bcoe/c8/compare/v7.8.0...v7.9.0) (2021-09-10)
|
|
6
13
|
|
|
7
14
|
|
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ Here is a list of common options. Run `c8 --help` for the full list and document
|
|
|
35
35
|
| `--all` | see [section below](#checking-for-full-source-coverage-using---all) for more info | `boolean` | `false` |
|
|
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
|
-
| `-x`, `--exclude` | see [section below](#checking-for-full-source-coverage-using---all) for more info | `Array<string>` | [list](https://github.com/istanbuljs/schema/blob/
|
|
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/main/default-exclude.js) |
|
|
39
39
|
| `--skip-full` | do not show files with 100% statement, branch, and function coverage | `boolean` | `false` |
|
|
40
40
|
| `--check-coverage` | check whether coverage is within thresholds provided | `boolean` | `false` |
|
|
41
41
|
| `--temp-directory` | directory V8 coverage data is written to and read from | `string` | `process.env.NODE_V8_COVERAGE` |
|
|
@@ -80,6 +80,24 @@ To check thresholds on a per-file basis run:
|
|
|
80
80
|
c8 check-coverage --lines 95 --per-file
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
If you want to check for 100% coverage across all dimensions, use `--100`:
|
|
84
|
+
|
|
85
|
+
```shell
|
|
86
|
+
c8 --100 npm test
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Is equivalent to
|
|
90
|
+
|
|
91
|
+
```shell
|
|
92
|
+
c8 --check-coverage --lines 100 --functions 100 --branches 100 --statements 100 npm test
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The `--100` flag can be set for the `check-coverage` as well:
|
|
96
|
+
|
|
97
|
+
```shell
|
|
98
|
+
c8 check-coverage --100
|
|
99
|
+
```
|
|
100
|
+
|
|
83
101
|
## Ignoring Uncovered Lines, Functions, and Blocks
|
|
84
102
|
|
|
85
103
|
Sometimes you might find yourself wanting to ignore uncovered portions of your
|
|
@@ -11,6 +11,14 @@ exports.builder = function (yargs) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
exports.handler = function (argv) {
|
|
14
|
+
// TODO: this is a workaround until yargs gets upgraded to v17, see https://github.com/bcoe/c8/pull/332#discussion_r721636191
|
|
15
|
+
if (argv['100']) {
|
|
16
|
+
argv.lines = 100
|
|
17
|
+
argv.functions = 100
|
|
18
|
+
argv.branches = 100
|
|
19
|
+
argv.statements = 100
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
const report = Report({
|
|
15
23
|
include: argv.include,
|
|
16
24
|
exclude: argv.exclude,
|
package/lib/commands/report.js
CHANGED
|
@@ -10,6 +10,14 @@ exports.handler = async function (argv) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
exports.outputReport = async function (argv) {
|
|
13
|
+
// TODO: this is a workaround until yargs gets upgraded to v17, see https://github.com/bcoe/c8/pull/332#discussion_r721636191
|
|
14
|
+
if (argv['100']) {
|
|
15
|
+
argv.checkCoverage = 100
|
|
16
|
+
argv.lines = 100
|
|
17
|
+
argv.functions = 100
|
|
18
|
+
argv.branches = 100
|
|
19
|
+
argv.statements = 100
|
|
20
|
+
}
|
|
13
21
|
const report = Report({
|
|
14
22
|
include: argv.include,
|
|
15
23
|
exclude: argv.exclude,
|
package/lib/parse-args.js
CHANGED
|
@@ -107,6 +107,12 @@ function buildYargs (withCommands = false) {
|
|
|
107
107
|
description: 'check thresholds per file',
|
|
108
108
|
type: 'boolean'
|
|
109
109
|
})
|
|
110
|
+
.option('100', {
|
|
111
|
+
default: false,
|
|
112
|
+
group: 'Coverage thresholds',
|
|
113
|
+
description: 'shortcut for --check-coverage --lines 100 --functions 100 --branches 100 --statements 100',
|
|
114
|
+
type: 'boolean'
|
|
115
|
+
})
|
|
110
116
|
.option('temp-directory', {
|
|
111
117
|
describe: 'directory V8 coverage data is written to and read from',
|
|
112
118
|
default: process.env.NODE_V8_COVERAGE
|
|
@@ -145,6 +151,19 @@ function buildYargs (withCommands = false) {
|
|
|
145
151
|
})
|
|
146
152
|
.epilog('visit https://git.io/vHysA for list of available reporters')
|
|
147
153
|
|
|
154
|
+
// TODO: enable once yargs upgraded to v17: https://github.com/bcoe/c8/pull/332#discussion_r721636191
|
|
155
|
+
// yargs.middleware((argv) => {
|
|
156
|
+
// if (!argv['100']) return argv
|
|
157
|
+
|
|
158
|
+
// return {
|
|
159
|
+
// ...argv,
|
|
160
|
+
// branches: 100,
|
|
161
|
+
// functions: 100,
|
|
162
|
+
// lines: 100,
|
|
163
|
+
// statements: 100,
|
|
164
|
+
// }
|
|
165
|
+
// })
|
|
166
|
+
|
|
148
167
|
const checkCoverage = require('./commands/check-coverage')
|
|
149
168
|
const report = require('./commands/report')
|
|
150
169
|
if (withCommands) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c8",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.10.0",
|
|
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,7 @@
|
|
|
37
37
|
"@istanbuljs/schema": "^0.1.2",
|
|
38
38
|
"find-up": "^5.0.0",
|
|
39
39
|
"foreground-child": "^2.0.0",
|
|
40
|
-
"istanbul-lib-coverage": "^3.0.
|
|
40
|
+
"istanbul-lib-coverage": "^3.0.1",
|
|
41
41
|
"istanbul-lib-report": "^3.0.0",
|
|
42
42
|
"istanbul-reports": "^3.0.2",
|
|
43
43
|
"rimraf": "^3.0.0",
|