Comparing version 7.11.0 to 7.11.1
export type Watermark = [number, number]; | ||
export declare class Report { | ||
constructor(opts: { | ||
exclude?: string | string[], | ||
extension?: string | string[], | ||
excludeAfterRemap?: boolean, | ||
include?: string | string[], | ||
reporter: string[], | ||
reportsDirectory?: string, | ||
tempDirectory?: string, | ||
watermarks?: Partial<{ | ||
statements: Watermark; | ||
functions: Watermark; | ||
branches: Watermark; | ||
lines: Watermark; | ||
}>, | ||
omitRelative?: boolean, | ||
wrapperLength?: number, | ||
resolve?: string, | ||
all?: boolean, | ||
src?: Array<string>, | ||
allowExternal?: boolean | ||
}) | ||
run(): Promise<void>; | ||
constructor(opts: { | ||
exclude?: string | string[], | ||
extension?: string | string[], | ||
excludeAfterRemap?: boolean, | ||
include?: string | string[], | ||
reporter: string[], | ||
reportsDirectory?: string, | ||
tempDirectory?: string, | ||
watermarks?: Partial<{ | ||
statements: Watermark; | ||
functions: Watermark; | ||
branches: Watermark; | ||
lines: Watermark; | ||
}>, | ||
omitRelative?: boolean, | ||
wrapperLength?: number, | ||
resolve?: string, | ||
all?: boolean, | ||
src?: Array<string>, | ||
allowExternal?: boolean | ||
}) | ||
run(): Promise<void>; | ||
} |
@@ -47,2 +47,3 @@ const Exclude = require('test-exclude') | ||
this.excludeAfterRemap = excludeAfterRemap | ||
this.shouldInstrumentCache = new Map() | ||
this.omitRelative = omitRelative | ||
@@ -100,3 +101,3 @@ this.sourceMapCache = {} | ||
if (this.excludeAfterRemap) { | ||
return !this.exclude.shouldInstrument(path) | ||
return !this._shouldInstrument(path) | ||
} | ||
@@ -292,3 +293,3 @@ }) | ||
if ((!this.omitRelative || isAbsolute(v8ScriptCov.url))) { | ||
if (this.excludeAfterRemap || this.exclude.shouldInstrument(v8ScriptCov.url)) { | ||
if (this.excludeAfterRemap || this._shouldInstrument(v8ScriptCov.url)) { | ||
result.push(v8ScriptCov) | ||
@@ -317,2 +318,19 @@ } | ||
} | ||
/** | ||
* this.exclude.shouldInstrument with cache | ||
* | ||
* @private | ||
* @return {boolean} | ||
*/ | ||
_shouldInstrument (filename) { | ||
const cacheResult = this.shouldInstrumentCache.get(filename) | ||
if (cacheResult !== undefined) { | ||
return cacheResult | ||
} | ||
const result = this.exclude.shouldInstrument(filename) | ||
this.shouldInstrumentCache.set(filename, result) | ||
return result | ||
} | ||
} | ||
@@ -319,0 +337,0 @@ |
{ | ||
"name": "c8", | ||
"version": "7.11.0", | ||
"version": "7.11.1", | ||
"description": "output coverage reports using Node.js' built in coverage", | ||
@@ -13,5 +13,5 @@ "main": "./index.js", | ||
"scripts": { | ||
"test": "node ./bin/c8.js mocha --timeout=8000 ./test/*.js", | ||
"coverage": "node ./bin/c8.js --check-coverage mocha --timeout=8000 ./test/*.js", | ||
"test:snap": "CHAI_JEST_SNAPSHOT_UPDATE_ALL=true npm test", | ||
"test": "cross-env TS_NODE_SKIP_PROJECT=true node ./bin/c8.js mocha --timeout=10000 ./test/*.js", | ||
"coverage": "cross-env TS_NODE_SKIP_PROJECT=true node ./bin/c8.js --check-coverage mocha --timeout=10000 ./test/*.js", | ||
"test:snap": "cross-env CHAI_JEST_SNAPSHOT_UPDATE_ALL=true npm test", | ||
"fix": "standard --fix", | ||
@@ -38,22 +38,23 @@ "posttest": "standard" | ||
"@bcoe/v8-coverage": "^0.2.3", | ||
"@istanbuljs/schema": "^0.1.2", | ||
"@istanbuljs/schema": "^0.1.3", | ||
"find-up": "^5.0.0", | ||
"foreground-child": "^2.0.0", | ||
"istanbul-lib-coverage": "^3.0.1", | ||
"istanbul-lib-coverage": "^3.2.0", | ||
"istanbul-lib-report": "^3.0.0", | ||
"istanbul-reports": "^3.0.2", | ||
"rimraf": "^3.0.0", | ||
"istanbul-reports": "^3.1.4", | ||
"rimraf": "^3.0.2", | ||
"test-exclude": "^6.0.0", | ||
"v8-to-istanbul": "^8.0.0", | ||
"v8-to-istanbul": "^9.0.0", | ||
"yargs": "^16.2.0", | ||
"yargs-parser": "^20.2.7" | ||
"yargs-parser": "^20.2.9" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16.9.1", | ||
"chai": "^4.2.0", | ||
"@types/node": "^17.0.23", | ||
"chai": "^4.3.6", | ||
"chai-jest-snapshot": "^2.0.0", | ||
"mocha": "^9.0.0", | ||
"standard": "^16.0.3", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.0.0" | ||
"cross-env": "^7.0.3", | ||
"mocha": "^9.2.2", | ||
"standard": "^16.0.4", | ||
"ts-node": "^10.7.0", | ||
"typescript": "^4.6.2" | ||
}, | ||
@@ -67,5 +68,4 @@ "engines": { | ||
"lib", | ||
"bin", | ||
"LICENSE" | ||
"bin" | ||
] | ||
} |
# c8 - native V8 code-coverage | ||
![ci](https://github.com/bcoe/c8/workflows/ci/badge.svg) | ||
![ci](https://img.shields.io/github/workflow/status/bcoe/c8/ci?label=ci&logo=github) | ||
![nycrc config on GitHub](https://img.shields.io/nycrc/bcoe/c8) | ||
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) | ||
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://www.conventionalcommits.org/) | ||
@@ -12,3 +12,3 @@ Code-coverage using [Node.js' built in functionality](https://nodejs.org/dist/latest-v10.x/docs/api/cli.html#cli_node_v8_coverage_dir) | ||
```bash | ||
```sh | ||
npm i c8 -g | ||
@@ -40,3 +40,3 @@ c8 node foo.js | ||
| `-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) | | ||
| `-e`, `--extension` | only files matching these extensions will show coverage | `string | Array<string>` | [list](https://github.com/istanbuljs/schema/blob/master/default-extension.js) | | ||
| `-e`, `--extension` | only files matching these extensions will show coverage | `string \| Array<string>` | [list](https://github.com/istanbuljs/schema/blob/master/default-extension.js) | | ||
| `--skip-full` | do not show files with 100% statement, branch, and function coverage | `boolean` | `false` | | ||
@@ -67,3 +67,3 @@ | `--check-coverage` | check whether coverage is within thresholds provided | `boolean` | `false` | | ||
```shell | ||
```sh | ||
c8 check-coverage --lines 95 --functions 95 --branches 95 | ||
@@ -75,3 +75,3 @@ ``` | ||
```shell | ||
```sh | ||
c8 --check-coverage --lines 100 npm test | ||
@@ -84,3 +84,3 @@ ``` | ||
```shell | ||
```sh | ||
c8 check-coverage --lines 95 --per-file | ||
@@ -91,3 +91,3 @@ ``` | ||
```shell | ||
```sh | ||
c8 --100 npm test | ||
@@ -98,3 +98,3 @@ ``` | ||
```shell | ||
```sh | ||
c8 --check-coverage --lines 100 --functions 100 --branches 100 --statements 100 npm test | ||
@@ -105,3 +105,3 @@ ``` | ||
```shell | ||
```sh | ||
c8 check-coverage --100 | ||
@@ -157,4 +157,3 @@ ``` | ||
c8 uses | ||
[native V8 coverage](https://github.com/nodejs/node/pull/22527), | ||
c8 uses [native V8 coverage](https://github.com/nodejs/node/pull/22527), | ||
make sure you're running Node.js `>= 10.12.0`. | ||
@@ -161,0 +160,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
798
34816
8
12
155
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Addedconvert-source-map@2.0.0(transitive)
+ Addedv8-to-istanbul@9.3.0(transitive)
- Removedconvert-source-map@1.9.0(transitive)
- Removedsource-map@0.7.4(transitive)
- Removedv8-to-istanbul@8.1.1(transitive)
Updated@istanbuljs/schema@^0.1.3
Updatedistanbul-lib-coverage@^3.2.0
Updatedistanbul-reports@^3.1.4
Updatedrimraf@^3.0.2
Updatedv8-to-istanbul@^9.0.0
Updatedyargs-parser@^20.2.9