https://github.com/simonecorsi/lcov-total
⚙️ Parse LCOV output and return the average value, easily fail CI with a threshold
https://github.com/simonecorsi/lcov-total
average ci cli coverage lcov node npm parser tdd test
Last synced: 18 days ago
JSON representation
⚙️ Parse LCOV output and return the average value, easily fail CI with a threshold
- Host: GitHub
- URL: https://github.com/simonecorsi/lcov-total
- Owner: simonecorsi
- License: mit
- Created: 2020-06-03T10:56:13.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-11T16:29:22.000Z (18 days ago)
- Last Synced: 2025-04-11T17:39:33.776Z (18 days ago)
- Topics: average, ci, cli, coverage, lcov, node, npm, parser, tdd, test
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/lcov-total
- Size: 2.34 MB
- Stars: 12
- Watchers: 1
- Forks: 2
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
lcov-total
[](https://github.com/prettier/prettier?style=flat-square)
[](https://github.com/semantic-release/semantic-release)

## Table of contents
- [About](#about)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)
- [Acknowledgements](#acknowledgements)## About
> This module now uses ESM modules from `v2.0.0`, if you need to use CommonJS refer to `v1.x.x`
This simple package aim to parse `lcov.info` files and provide the total coverage `Number` without fancy formatting or anything else, either in stdout or programmatically.
Here's why:
- You need to assest coverage in your CI and fail below certain threshold
- you don't want to do unredable `awk` chains
- every other options outputs fancy colored output which is tediuous to parse and error prone## Installation
You can install locally
```sh
npm install lcov-total
```You can install globally
```sh
npm install -g lcov-total
```Or use NPX
```sh
npx lcov-total
```## Usage
You can use `lcov-total` from command line providing `lcov.info` file location eg:
```sh
npx lcov-total lcov.info
# 100.00
```If you pass the `--gte=value` flag you will get an exitCode 0 or 1 based on resulting `coverage >= value` expression, eg:
```sh
npx lcov-total lcov.info --gte=90
echo $?
# 0
```Or programmatically
```js
import lcovTotal from "lcov-total";
lcovTotal("/path/to/lcov.info"); // this throws if any error
```## Contributing
Project is pretty simple and straight forward for what is my needs, but if you have any idea you're welcome.
This projects uses [commitlint](https://commitlint.js.org/) with Angular configuration so be sure to use standard commit format or PR won't be accepted.
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'feat(scope): some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request## License
Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.
## Contact
Simone Corsi - [@im_simonecorsi](https://twitter.com/im_simonecorsi)
## Acknowledgements
- [lcov parsing mega switch](https://github.com/davglass/lcov-parse) - from davglass