Creates README badges from istanbul coverage report
Statements | Branches | Functions | Lines |
---|---|---|---|
- Example Markup
- Example Running
- Requirements
- Installation
- Usage
- Using as a part of your githooks
- License
| Statements | Branches | Functions | Lines |
| ------------------------- | ----------------------- | ------------------------ | -------------------- |
| ![Statements](#branches#) | ![Branches](#branches#) | ![Functions](#branches#) | ![Lines](#branches#) |
- The table is optional, the only markups that matters are the following:
![Statements]
![Branches]
![Functions]
![Lines]
- *Must have at least one of the before mentioned markup items;
- You should have json-summary as a coverageReporter in your tests configuration;
- For example, if you are using Jest, configuration should either be within
package.json
or inside your jest config file i.e.jest.config.js
orjestconfig.json
as shown below:
"coverageReporters": ["json-summary"]
npm i -D istanbul-badges-readme
- Simply run it from the CLI as follows:
npm run istanbul-badges-readme
- With custom coverage directory:
npm run istanbul-badges-readme --coverageDir="./my-custom-coverage-directory"
- Or add it to your package.json scripts as follows:
"scripts": {
"make-badges": "istanbul-badges-readme",
}
- If you want to have this run on the pre-commit hook and update the commit in place, just install husky and add the
pre-commit
script to your package.json.
- Install Husky.
npm install -D husky
- Add your pre-commit script:
"husky": {
"hooks": {
"pre-commit": "npm run test && istanbul-badges-readme && git add 'README.md'"
}
}
- Git Commit and Push. Just use your workflow as usual. If your tests fail, no commit. If they pass, update the README.md and add the file to the commit. Nice!
Thanks goes to these wonderful people (emoji key):
Olavo Parno ๐ค ๐ป | nothingismagick ๐ค ๐ ๐ | Dave Fisher ๐ |
This project follows the all-contributors specification. Contributions of any kind welcome!
Istanbul Badges Readme is MIT licensed.