Creates README badges from istanbul coverage report
Statements | Branches | Functions | Lines |
---|---|---|---|
- Markup example
- Running example
- Requirements
- Installation
- Usage
- Usage as a part of your githooks
- See more examples
- Contributors
- License
| Statements | Branches | Functions | Lines |
| --------------------------- | ----------------------- | ------------------------- | -------------------- |
| ![Statements](#statements#) | ![Branches](#branches#) | ![Functions](#functions#) | ![Lines](#lines#) |
- The table is optional, the only markup that matters are the following:
![Statements](#statements#)
![Branches](#branches#)
![Functions](#functions#)
![Lines](#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"]
- See more in the examples.
npm i -D istanbul-badges-readme
- Simply run it from the CLI as follows:
npm run istanbul-badges-readme
- Custom coverage directory? Use --coverageDir argument:
npm run istanbul-badges-readme --coverageDir="./my-custom-coverage-directory"
- Want it without logging? Try silent mode with --silent argument:
npm run istanbul-badges-readme --silent
- 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 🐛 |
Martin Zagora 🤔 🐛 |
Victor Miti 🐛 |
Stefan Huber 💬 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!
Istanbul Badges Readme is MIT licensed.