Skip to content

Commit 7233255

Browse files
committed
feat: add --from file support to check-coverage
1 parent e754a22 commit 7233255

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.nyc_output/no-information.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"no-coverage.js": {
3+
"path": "no-coverage.js",
4+
"s": {}
5+
}
6+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ By default `only-covered` script reads `.nyc_output/out.json` file from the curr
1717

1818
```shell
1919
only-covered --from examples/exclude-files/coverage/coverage-final.json main.js
20+
check-coverage --from examples/exclude-files/coverage/coverage-final.json main.js
2021
```
2122

2223
[ci image]: https://github.com/bahmutov/check-code-coverage/workflows/ci/badge.svg?branch=master

bin/check-coverage.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
#!/usr/bin/env node
22
// @ts-check
3-
const { join } = require('path')
3+
const { join, resolve } = require('path')
4+
const arg = require('arg')
45

5-
const filename = process.argv[2]
6+
const args = arg({
7+
'--from': String, // input filename, by default ".nyc_output/out.json"
8+
})
9+
10+
const filename = args._[0]
611
if (!filename) {
712
console.error('Usage: node %s <file name>', __filename)
813
process.exit(1)
914
}
10-
const coverageFilename = join(process.cwd(), '.nyc_output', 'out.json')
15+
16+
const fromFilename = args['--from'] || join('.nyc_output', 'out.json')
17+
const coverageFilename = resolve(fromFilename)
18+
1119
const coverage = require(coverageFilename)
1220
const fileCoverageKey = Object.keys(coverage).find(name => {
1321
const fileCover = coverage[name]

0 commit comments

Comments
 (0)