Compare commits

...

56 commits
v0.0.2 ... 0.x

Author SHA1 Message Date
3e3d0b5a9d feat: sapling scm support
All checks were successful
CI / Lint (pull_request) Successful in 29s
CI / Test Node (pull_request) Successful in 32s
Conventional Tools Commitlint / Commitlint (pull_request) Successful in 5s
CI / Lint (push) Successful in 27s
CI / Test Node (push) Successful in 32s
Conventional Tools Commitlint / Commitlint (push) Successful in 5s
Now you can run this inside a sapling repo. It will automatically pick what
source control you are using by checking for the root repo.
2024-09-17 08:29:43 +01:00
7610b3bef5 ci: install yarn for actions on forgejo (#2)
All checks were successful
CI / Lint (push) Successful in 29s
CI / Test Node (push) Successful in 31s
Conventional Tools Commitlint / Commitlint (push) Successful in 5s
Summary:

The forgejo action use act under the hood. The default image does not have yarn
installed so, this is installing it.

Test Plan:

CI

Reviewed By: AdeAttwood

Pull Request: #2
Co-authored-by: Ade Attwood <adrian.attwood@marketdojo.com>
Co-committed-by: Ade Attwood <adrian.attwood@marketdojo.com>
2024-09-17 07:13:34 +00:00
renovate[bot]
0d9a76760d chore(deps): update testing packages 2024-01-23 09:02:13 +00:00
renovate[bot]
903e29b7d1 chore(deps): update eslint packages to v6.19.1 2024-01-23 08:09:18 +00:00
renovate[bot]
ff506d4679 chore(deps): lock file maintenance 2024-01-14 16:01:53 +00:00
1b3a85465f chore: update eslint prettier
This updates the following packages, they need to be updated together.

- eslint-config-prettier
- eslint-plugin-prettier
2024-01-14 15:56:21 +00:00
47f5f93b72 chore: update eslint 2024-01-14 15:48:03 +00:00
01c927e131 chore: update dependencies 2023-08-26 10:37:57 +01:00
a10d2819b3 feat: exit with non-zero status code if coverage is below 90% 2023-08-26 10:32:42 +01:00
186c5754d7 ci: run tests on multiple node versions 2023-08-16 19:56:50 +01:00
1d464addfd chore: update dev dependencies 2023-08-16 19:56:50 +01:00
c8ce7f37bd feat: add diffing of lcov files 2023-08-16 19:43:39 +01:00
renovate[bot]
b1c14afd65 chore(deps): lock file maintenance 2023-06-25 05:24:47 -07:00
renovate[bot]
2781d8a124 chore(deps): update eslint packages 2023-06-25 05:24:18 -07:00
renovate[bot]
15724af2ad chore(deps): update dependency @types/node to v18.16.18 2023-06-15 23:00:58 -07:00
github-actions[bot]
46fcffb95c chore(release): v0.2.0 [skip ci] 2023-06-13 13:22:29 +00:00
renovate[bot]
da6a7a1967 chore(deps): update dependency typescript to v5.1.3 2023-06-13 06:21:05 -07:00
renovate[bot]
372b607184 chore(deps): update eslint packages 2023-06-13 06:20:57 -07:00
renovate[bot]
b23715bb85 chore(deps): update dependency @types/jest to v29.5.2 2023-06-13 06:20:41 -07:00
renovate[bot]
b6ce8ea652 chore(deps): update dependency @types/node to v18.16.17 2023-06-13 06:20:28 -07:00
9192e62995 feat: update the coverage to exclude "normal" lines
This will now exclude lines that are not added or edited in the diff.
They are lines that are included in the diff context but will still
count towards the coverage percentage.

You now get a more accurate coverage percentage from what you have
edited in the diff.
2023-06-13 06:20:15 -07:00
github-actions[bot]
797f97e867 chore(release): v0.1.0 [skip ci] 2023-05-31 15:40:44 +00:00
fdd59c115d ci: add safe.directory to git config 2023-05-31 16:30:39 +01:00
renovate[bot]
03a5695092 chore(deps): lock file maintenance 2023-05-31 16:27:52 +01:00
renovate[bot]
d1a0bc543b chore(deps): update eslint packages 2023-05-31 16:26:36 +01:00
renovate[bot]
b4793164c4 chore(deps): update testing packages 2023-05-31 16:25:01 +01:00
renovate[bot]
6d87ecd352 chore(deps): update dependency prettier to v2.8.8 2023-05-31 16:24:36 +01:00
renovate[bot]
4b8ba107a3 chore(deps): update dependency typescript to v5.0.4 2023-05-31 16:24:17 +01:00
renovate[bot]
cb7441db1d fix(deps): update dependency yargs to v17.7.2 2023-05-31 16:24:00 +01:00
renovate[bot]
e455a1ad79 chore(deps): update dependency @types/node to v18.16.16 2023-05-31 16:23:47 +01:00
e5fa389bdc chore: move to conventional-tools docker hub image 2023-05-31 16:23:26 +01:00
renovate[bot]
3470363a8a chore(deps): update eslint packages to v5.57.1 2023-04-06 21:42:50 +01:00
renovate[bot]
39a417d9dc chore(deps): update dependency typescript to v5 2023-03-31 08:00:55 +01:00
renovate[bot]
da330eb4f1 chore(deps): update testing packages to v29.5.0 2023-03-31 08:00:26 +01:00
renovate[bot]
99852c07c8 chore(deps): update eslint packages 2023-03-31 07:59:54 +01:00
renovate[bot]
28eaf57857 chore(deps): update dependency prettier to v2.8.7 2023-03-31 07:58:51 +01:00
renovate[bot]
312cb194b1 chore: add renovate.json 2023-03-27 19:34:09 +01:00
092985baf7 chore: update github actions
Update the node version to be consistent between the tests and
publishing.

Adds yarn cacheing to the setup-node action.

Adds a conditional action for the publishing so we don't publish a
release the release tagging fails.
2023-02-10 08:01:53 +00:00
eff06a2ca9 chore: update dependencies 2023-02-10 08:01:53 +00:00
dependabot[bot]
e261b5c7c1 chore(deps): bump json5 from 2.2.1 to 2.2.3
Bumps [json5](https://github.com/json5/json5) from 2.2.1 to 2.2.3.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v2.2.1...v2.2.3)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-09 19:02:42 +00:00
4d3d48c372 chore: update typescript and associated packages
Direct packages that have been upgraded

 - typescript

All packages upgraded including indirect dependencies

 - typescript@4.9.4
2023-01-09 17:31:08 +00:00
ffa4c6e0fa chore: update prettier and associated packages
Direct packages that have been upgraded

 - prettier

All packages upgraded including indirect dependencies

 - prettier@2.8.2
2023-01-09 17:31:08 +00:00
f5cd033fd7 chore: update eslint and associated packages
Direct packages that have been upgraded

 - @typescript-eslint/eslint-plugin
 - @typescript-eslint/parser
 - eslint
 - eslint-config-prettier

All packages upgraded including indirect dependencies

 - @typescript-eslint/eslint-plugin@5.48.1
 - @typescript-eslint/parser@5.48.1
 - eslint@8.31.0
 - eslint-config-prettier@8.6.0
 - @eslint/eslintrc@1.4.1
 - @humanwhocodes/config-array@0.11.8
 - @typescript-eslint/type-utils@5.48.1
2023-01-09 17:31:08 +00:00
72bbfc1896 chore: update node and associated packages
Direct packages that have been upgraded

 - @types/node

All packages upgraded including indirect dependencies

 - @types/node@18.11.18
2023-01-09 17:31:08 +00:00
f7b304903b chore: update jest and associated packages
Direct packages that have been upgraded

 - @types/jest

All packages upgraded including indirect dependencies

 - @types/jest@29.2.5
2023-01-09 17:31:08 +00:00
462048fb12 ci: make the current directory safe for git
This is also done in actions/checkout but for some reason dose not work.
I think its got something to do with us using a container for the
action.
2023-01-09 17:31:08 +00:00
5faed672ff chore: update typescript and associated packages
Direct packages that have been upgraded

 - typescript

All packages upgraded including indirect dependencies

 - typescript@4.9.3
2022-11-18 15:43:41 +00:00
bf972e6a68 chore: update eslint and associated packages
Direct packages that have been upgraded

 - @typescript-eslint/eslint-plugin
 - @typescript-eslint/parser

All packages upgraded including indirect dependencies

 - @typescript-eslint/eslint-plugin@5.43.0
 - @typescript-eslint/parser@5.43.0
 - @typescript-eslint/type-utils@5.43.0
2022-11-18 15:43:41 +00:00
7b68e03fe0 chore: update jest and associated packages
Direct packages that have been upgraded

 - @types/jest

All packages upgraded including indirect dependencies

 - @types/jest@29.2.3
2022-11-18 15:43:41 +00:00
7e58639613 chore: update jest and associated packages
Direct packages that have been upgraded

 - jest

All packages upgraded including indirect dependencies

 - jest@29.3.1
 - diff-sequences@29.3.1
 - jest-cli@29.3.1
 - jest-resolve-dependencies@29.3.1
 - @jest/reporters@29.3.1
 - @jest/globals@29.3.1
 - @jest/test-sequencer@29.3.1
 - jest-circus@29.3.1
 - jest-leak-detector@29.3.1
 - babel-jest@29.3.1
 - jest-each@29.3.1
2022-11-10 10:04:53 +00:00
c714351ceb chore: update eslint and associated packages
Direct packages that have been upgraded

 - @typescript-eslint/eslint-plugin
 - @typescript-eslint/parser
 - eslint

All packages upgraded including indirect dependencies

 - @typescript-eslint/eslint-plugin@5.42.1
 - @typescript-eslint/parser@5.42.1
 - eslint@8.27.0
 - @typescript-eslint/type-utils@5.42.1
2022-11-10 10:04:53 +00:00
a96efcbc81 chore: update yargs and associated packages
Direct packages that have been upgraded

 - yargs

All packages upgraded including indirect dependencies

 - yargs@17.6.2
2022-11-05 09:27:55 +00:00
74c9788d99 chore: update jest and associated packages
Direct packages that have been upgraded

 - @types/jest

All packages upgraded including indirect dependencies

 - @types/jest@29.2.2
2022-11-05 09:27:55 +00:00
8fc3ee88d2 chore: update dependencies
- @types/jest@29.2.1
- @types/node@18.11.9
- @typescript-eslint/eslint-plugin@5.42.0
- @typescript-eslint/parser@5.42.0
- jest@29.2.2
- natural-compare-lite@1.4.0
- @typescript-eslint/type-utils@5.42.0
- jest-cli@29.2.2
- jest-resolve-dependencies@29.2.2
- @jest/reporters@29.2.2
- @jest/globals@29.2.2
- @jest/test-sequencer@29.2.2
- jest-circus@29.2.2
- babel-jest@29.2.2
2022-11-02 08:27:32 +00:00
5792d09de4 docs: update the readme 2022-10-25 07:31:41 +01:00
e20a3d3747 feat: add better error message when the coverageFile is not found 2022-10-25 07:30:26 +01:00
12 changed files with 1367 additions and 1020 deletions

View file

@ -5,16 +5,21 @@ on:
pull_request: { branches: ["0.x"] }
jobs:
test:
name: Test
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install yarn
run: npm i -g yarn
- name: Set up Node
uses: actions/setup-node@v2
with: { node-version: 18 }
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- name: Install dependencies
run: yarn install
@ -25,5 +30,28 @@ jobs:
- name: Type Check
run: yarn build
test:
name: Test Node ${{ matrix.node-versions }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [16, 18, 20]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install yarn
run: npm i -g yarn
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install dependencies
run: yarn install
- name: Test
run: yarn test --coverage

View file

@ -8,11 +8,14 @@ jobs:
commits:
name: Commitlint
runs-on: ubuntu-latest
container: registry.k1.zportal.co.uk/practically-oss/conventional-tools:1.x
container: practically/conventional-tools:1.x@sha256:647d6e4b3edfcbac6054b90f74d2c61a022152751b94484d54e13695a9e27377
steps:
- name: Checkout
uses: actions/checkout@v3
with: {fetch-depth: 1000}
- name: Git safe.directory
run: git config --global --add safe.directory $PWD
- name: Lint commits
run: conventional-tools commitlint -l1

View file

@ -11,7 +11,7 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
container: registry.k1.zportal.co.uk/practically-oss/conventional-tools:1.x
container: practically/conventional-tools:1.x@sha256:647d6e4b3edfcbac6054b90f74d2c61a022152751b94484d54e13695a9e27377
env:
CT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
@ -20,6 +20,9 @@ jobs:
with:
fetch-depth: 0
- name: Git safe.directory
run: git config --global --add safe.directory $PWD
- name: Setup Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"

View file

@ -8,15 +8,17 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '14'
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: yarn
- name: Install dependencies and build
run: yarn install && yarn build

View file

@ -1,3 +1,20 @@
# [v0.2.0](https://github.com/AdeAttwood/DiffCov/compare/v0.1.0...v0.2.0) (2023-06-13)
### Features
* update the coverage to exclude "normal" lines ([9192e62](https://github.com/AdeAttwood/DiffCov/commit/9192e6299547bfb18106af22363f1d10ecfa6ec6))
# [v0.1.0](https://github.com/AdeAttwood/DiffCov/compare/v0.0.2...v0.1.0) (2023-05-31)
### Bug Fixes
* **deps:** update dependency yargs to v17.7.2 ([cb7441d](https://github.com/AdeAttwood/DiffCov/commit/cb7441db1d886d39a9fba5c3dd908cf75efd8173))
### Features
* add better error message when the `coverageFile` is not found ([e20a3d3](https://github.com/AdeAttwood/DiffCov/commit/e20a3d3747157a9c4830cd4454850f19aa2b2819))
## [v0.0.2](https://github.com/AdeAttwood/DiffCov/compare/v0.0.1...v0.0.2) (2022-10-24)
### Bug Fixes

View file

@ -2,6 +2,87 @@
# Diff Cov
Simple CLI to print diffs highlighted with test coverage status
Simple CLI to print git and lcov diffs highlighted with test coverage status
![Example Output](assets/example-output.png)
</div>
## Installation
You can install the package with npm
```bash
npm i -g @adeattwood/diff-cov
```
You can run it directly with `npx`
```bash
npx @adeattwood/diff-cov
```
## Setup
For diff-cov to get the diff to your default branch, you must set up your
`origin/HEAD` ref. To test to see if you have this set up, run.
```bash
git rev-parse --abbrev-ref origin/HEAD
```
This should print out the origin ref to your default branch for this repo it
will print `origin/0.x`. If you get an unknown ref error, then you will need to
link `origin/HEAD` to your default branch with the below command.
```bash
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/0.x
```
> **Note**:
> Make sure you change `0.x` for your default branch name typically `main` or
> `development`
## Usage
### Git diff
Before you run `diff-cov` you must run your test suite with coverage and output
a `lcov` coverage file. You must also have all your changes committed to ensure
it's included in the output.
Once you are ready to go, you can run `diff-cov` to print your diff highlighted
with coverage status. Any line not included in the coverage report will not be
highlighted and hit and missed lines will be colored green and red. You can use
the `--coverageFile` flag to specify the path to your coverage report if its
not in the default location of `./lcov.info`
```bash
diff-cov
diff-cov --coverageFile coverage/lcov.info
```
A report is printed at the bottom and colored with a threshold of `90%`
anything below this percentage coverage will be colored red.
### LCov diff
You can also print the coverage difference between to lcov.info files. To use
this run your tests with coverage for a first time. After its finished you can
copy your lcov.info file somewhere for later for example:
```shell
cp ./lcov.info /tmp/lcov.info
```
Then you can work on your test and run the tests once more with coverage to
generate you a new `lcov.info` file. Then you can print the difference in
coverage between the two files with:
```shell
diff-cov --compare /tmp/lcov.info
```
This can come in handy when you need to find out what a test is testing. You
can create your base coverage file, comment out a test, run the tests again and
diff the results.

View file

@ -1,6 +1,6 @@
{
"name": "@adeattwood/diff-cov",
"version": "0.0.2",
"version": "0.2.0",
"description": "Simple CLI to get test coverage on a diff",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
@ -28,20 +28,20 @@
"build": "tsc"
},
"dependencies": {
"yargs": "^17.3.1"
"yargs": "^17.6.2"
},
"devDependencies": {
"@types/jest": "^29.1.1",
"@types/node": "^18.11.4",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.1.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"@types/jest": "^29.5.4",
"@types/node": "^20.5.0",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.6.4",
"prettier": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
"typescript": "^5.1.6"
}
}
}

24
renovate.json Normal file
View file

@ -0,0 +1,24 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"],
"lockFileMaintenance": { "enabled": true },
"packageRules": [
{
"matchPackageNames": ["node"],
"allowedVersions": "<=16"
},
{
"matchPackageNames": ["ts-jest", "@types/jest"],
"matchPackagePatterns": ["^jest", "^@testing-library/"],
"groupName": "testing packages"
},
{
"matchPackagePatterns": ["^eslint", "^@typescript-eslint/"],
"groupName": "eslint packages"
},
{
"matchPackageNames": ["react", "react-dom", "@types/react", "@types/react-dom"],
"groupName": "react packages"
}
]
}

View file

@ -1,9 +1,11 @@
import yargs from "yargs";
import type { Options } from "yargs";
import fs from "fs";
import type { Options, Arguments } from "yargs";
import { hideBin } from "yargs/helpers";
import exec from "./exec";
import report from "./report";
import lcovDiff from "./lcov-diff";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const parseDiff = require("./diff-parser");
@ -11,7 +13,7 @@ const parseDiff = require("./diff-parser");
const parseLcov = require("./lcov-parser");
export const error = (message: string) => {
console.error(message);
console.error("[ERROR] " + message);
};
const options: { [key: string]: Options } = {
@ -20,18 +22,87 @@ const options: { [key: string]: Options } = {
description: "The path to the lcov report file",
type: "string",
},
compare: {
description: "The path to the lcov report you wish to compare to the `coverage-file`",
type: "string",
},
};
export const run = async (argv = process.argv) => {
const parsed: any = yargs(hideBin(argv)).options(options).argv;
type Argv = Arguments<
Partial<{
coverageFile: string;
compare?: string;
}>
>;
const diffText = await exec(`git diff origin/HEAD...HEAD`);
if (diffText.code > 0) {
return error("Error loading the diff\n\n" + diffText.stderr);
export const validate = async (argv: Argv) => {
if (!fs.existsSync(argv.coverageFile || "")) {
return new Error(
`Lcov file must be a valid file '${argv.coverageFile}' provided. ` +
`Please ensure you have run tests with coverage enabled.`
);
}
const diff = parseDiff.default(diffText.stdout);
const coverage = await parseLcov.default(parsed.coverageFile);
report(diff, coverage);
if (argv.compare && !fs.existsSync(argv.compare)) {
return new Error(`Lcov compare file must be a valid file '${argv.compare}' provided.`);
}
};
async function isGitRepo() {
const isGit = await exec(`git rev-parse --is-inside-work-tree`);
return isGit.code === 0;
}
async function isSaplingRepo() {
const isSapling = await exec(`sl root`);
return isSapling.code === 0;
}
async function getDiff(): Promise<string | undefined> {
if (await isGitRepo()) {
const diffText = await exec(`git diff origin/HEAD...HEAD`);
if (diffText.code > 0) {
error("Error loading the diff\n\n" + diffText.stderr);
return undefined;
}
return diffText.stdout;
}
if (await isSaplingRepo()) {
const diffText = await exec(`sl diff -g -r '. % public()'`);
if (diffText.code > 0) {
error("Error loading the diff\n\n" + diffText.stderr);
return undefined;
}
return diffText.stdout;
}
error("Unable to get a diff no repo was found\n");
}
export const run = async (argv = process.argv) => {
const parsed: Argv = await yargs(hideBin(argv)).options(options).argv;
const validationError = await validate(parsed);
if (validationError instanceof Error) {
return error(validationError.message);
}
const baseCoverage = await parseLcov.default(parsed.coverageFile);
if (parsed.compare) {
const compareCoverage = await parseLcov.default(parsed.compare);
return lcovDiff(baseCoverage, compareCoverage);
}
const diffText = await getDiff();
if (!diffText) {
return;
}
const diff = parseDiff.default(diffText);
const { percentage } = report(diff, baseCoverage);
process.exit(percentage > 90 ? 0 : 1);
};

40
src/lcov-diff.ts Normal file
View file

@ -0,0 +1,40 @@
const buildCoverageSet = (report: any) => {
const set = new Set<string>();
for (const coverage of report) {
for (const detail of coverage.lines.details) {
if (detail.hit > 0) {
set.add(`${coverage.file}:${detail.line}`);
}
}
}
return set;
};
function setDiff<T>(a: Set<T>, b: Set<T>) {
return new Set([...a].filter((x) => !b.has(x)));
}
export const lcovDiff = async (baseCoverage: any, compareCoverage: any) => {
const baseSet = buildCoverageSet(baseCoverage);
const compareSet = buildCoverageSet(compareCoverage);
const map = new Map<string, number>();
const added = setDiff(baseSet, compareSet);
for (const key of added) {
map.set(key, 1);
}
const removed = setDiff(compareSet, baseSet);
for (const key of removed) {
map.set(key, 0);
}
for (const [key, value] of [...map.entries()].sort()) {
const color = value > 0 ? "\x1b[32m" : "\x1b[31m";
console.log(color, key, "\x1b[0m");
}
};
export default lcovDiff;

View file

@ -1,7 +1,7 @@
const getCoverageForFile = (file: any, coverage: any) => {
for (const cov of coverage) {
const report: { [k: number]: number } = {};
if (cov.file === file.to) {
if (cov.file.replace("./", "") === file.to) {
for (const detail of cov.lines.details) {
report[detail.line] = detail.hit;
}
@ -35,7 +35,7 @@ interface Diff {
}
export const printReport = (diff: Diff[], coverage: any) => {
const report = { total: 0, covered: 0 };
const report = { total: 0, covered: 0, percentage: 0 };
for (const file of diff) {
const fileCoverage = getCoverageForFile(file, coverage);
@ -54,7 +54,14 @@ export const printReport = (diff: Diff[], coverage: any) => {
if (change.type === "del") {
continue;
}
const line = change.ln || change.ln2;
if (change.type === "normal") {
console.log(line.toString().padStart(4, " "), "\x1b[0m", change.content.substring(1), "\x1b[0m");
continue;
}
let color = "\x1b[0m";
if (typeof fileCoverage[line] !== "undefined") {
color = fileCoverage[line] > 0 ? "\x1b[32m" : "\x1b[31m";
@ -70,13 +77,13 @@ export const printReport = (diff: Diff[], coverage: any) => {
}
}
const percentage = (report.covered / report.total) * 100;
const color = percentage > 90 ? "\x1b[32m" : "\x1b[31m";
report.percentage = (report.covered / report.total) * 100;
const color = report.percentage > 90 ? "\x1b[32m" : "\x1b[31m";
console.log("");
console.log("Total Lines: ", report.total.toString());
console.log("Lines Covered: ", report.covered.toString());
console.log("Coverage Percentage", color, percentage.toString() + "%", "\x1b[0m");
console.log("Coverage Percentage", color, report.percentage.toString() + "%", "\x1b[0m");
return report;
};

2033
yarn.lock

File diff suppressed because it is too large Load diff