Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
istanbul-badges-readme
Advanced tools
Creates README badges from istanbul coverage report
Statements | Branches | Functions | Lines |
---|---|---|---|
package.json
or inside your jest config file i.e. jest.config.js
or jestconfig.json
as written below: "coverageReporters": ["json-summary"]
npm i -D istanbul-badges-readme
Add at least one of the below coverage hashes in your README file:
![Statements](#statements#)
![Branches](#branches#)
![Functions](#functions#)
![Lines](#lines#)
A simple example of all hashes being used in a table fashion markup:
| Statements | Branches | Functions | Lines |
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
| ![Statements](#statements#) | ![Branches](#branches#) | ![Functions](#functions#) | ![Lines](#lines#) |
npx istanbul-badges-readme
"scripts": {
"make-badges": "istanbul-badges-readme",
}
npm run istanbul-badges-readme --coverageDir="./my-custom-coverage-directory"
npm run istanbul-badges-readme --readmeDir="./my-custom-readme-directory"
npm run istanbul-badges-readme --silent
npm run istanbul-badges-readme --functionsLabel='Mis funciones!' --branchesLabel='Branches are troublesome!'
npm run istanbul-badges-readme --style="for-the-badges"
npm run istanbul-badges-readme --logo="jest"
--colors
argument. If you want red badges for a code coverage below 50% and yellow badges for a coverage below 60%, you'd do this: npm run istanbul-badges-readme --colors=red:50,yellow:60
npm run istanbul-badges-readme --exitCode=1
pre-commit
script to your package.json. npm install -D husky
"husky": {
"hooks": {
"pre-commit": "npm run test && istanbul-badges-readme && git add 'README.md'"
}
}
You may want to have peace of mind that contributors have run istanbul-badges-readme
locally by performing a simple check in your CI.
The --ci
argument will throw an error, code 0 by default unless exitCode is specified, thus not updating anything regarding coverage, if the badges generated do not match what is already in the README.md
.
You can add this to your package.json as follows for exitCode 0:
"scripts": {
"make-badges": "istanbul-badges-readme",
"make-badges:ci": "npm run make-badges -- --ci",
}
Also if you wish a different exitCode:
"scripts": {
"make-badges": "istanbul-badges-readme",
"make-badges:ci": "npm run make-badges -- --ci --exitCode=1",
}
This is a useful addition/alternative to the githooks approach for some use cases such as larger codebases, slow computers etc, where it isn't always feasible to run all the tests and produce coverage on each commit.
DEFAULT STYLE Square style='square'
:
Square flat style='square-flat'
:
Plastic style='plastic'
:
For the badge style='for-the-badge'
:
✔️ Tip
We use this in our pull request GitHub Action, check out a recent pull request to see it in action!
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Istanbul Badges Readme is MIT licensed.
FAQs
Creates README badges from istanbul coverage report
The npm package istanbul-badges-readme receives a total of 8,416 weekly downloads. As such, istanbul-badges-readme popularity was classified as popular.
We found that istanbul-badges-readme demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.