the-bugging / istanbul-badges-readme Goto Github PK
View Code? Open in Web Editor NEWCreates and updates README testing coverage badges with your json-summary
Home Page: https://www.npmjs.com/package/istanbul-badges-readme
License: MIT License
Creates and updates README testing coverage badges with your json-summary
Home Page: https://www.npmjs.com/package/istanbul-badges-readme
License: MIT License
Is your feature request related to a problem? Please describe.
Make the CLI exit with non-zero code if validation fails
Current behavior:
$ istanbul-badges-readme
Info: 0. Istanbul Badges Readme process started
Info: 1. Config check process started
- Readme file exists... ✔️.
Error: Coverage file does not exist in ./coverage/coverage-summary.json
Error: Please refer to the documentation
Error: https://github.com/olavoparno/istanbul-badges-readme/blob/master/README.md
Info: 0. Istanbul Badges Readme process finished
Done in 0.17s.
$ echo $?
0
Exiting with 0 prevent other tools (like GitHub Actions) to detect any validation errors of istanbul-badges-readme
easily
Describe the solution you'd like
adding process.exitCode = 1;
below will do the trick work but I'm pretty sure it will be a breaking change as some users could be relying on istanbul-badges-readme success exit code
thus, to avoid breaking changes, this feat could be optional and enabled via --exit-code
flag, like git-diff
do
Describe alternatives you've considered
In my use case, the coverage directory might not exists and I need to report this as an error. I'm doing the following:
$ [ -d './coverage' ] && istanbul-badges-readme || exit 1
but I think it would be cool if istanbul-badges-readme
abstracts this for us :)
Is your feature request related to a problem? Please describe.
A badge has a few style: flat, plastic, flat-square, etc. Maybe it's a good choice to specify via --style
custom argument.
Describe the solution you'd like
via --style
argument
Describe alternatives you've considered
Additional context
First of all, I'd like to thank you for this excellent package, this is absolutely great! Everything seems to work just fine, except I've noticed that if coverage is 0%, the badge isn't generated and hence substitution doesn't take place. For example, in my case, I had the following results:
=============================== Coverage summary ===============================
Statements : 6.25% ( 1/16 )
Branches : 0% ( 0/4 )
Functions : 20% ( 1/5 )
Lines : 7.14% ( 1/14 )
================================================================================
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 1 passed, 1 total
Time: 6.294s
Ran all test suites.
This resulted in
Statements | Functions | Lines | Branches |
---|---|---|---|
Thanks
Describe the bug
Hi! I was trying to run the script with npm following the steps in the documentation. However, it was always failing in this part of the process:
Since I'm not running with the ci flag or in a ci environment, i went into the codebase to search how was this error message thrown. I found that the getArgumentValue function searches a string with indexOf only:
The problem with this is that for users who have user names, or node path, or maybe any other line in the process.argv with the 'ci' substring, the item.indexof(argName) >= 0
returns true:
In my case, changing my user and nvm path worked.
To Reproduce
Steps to reproduce the behavior:
Additional context
I was unsure if this is a node version related problem, but trying to run with v14.18.1 or 16.15.1 didnt work. Happy to help tho! Will submit a PR soon!
I did run npm run istanbul-badges-readme
after that readme says you can run npm run istanbul-badges-readme
but I cannot. It says
npm ERR! Missing script: "istanbul-badges-readme"
This is a very small thing. Thanks for this great library!
Describe the bug
Even when the user doesn't have writting permission on the README file, logging saids everything went fine
To Reproduce
Additional context
The issue is that the following doesn't take account file permissions
also, fs.exists
has been deprecated in favor of fs.stat
or fs.access
To fix that, I added the following line right before L10 from above:
fs.accessSync(getReadmePath(readmePath), fs.constants.R_OK | fs.constants.W_OK)
and got:
Info: 0. Istanbul Badges Readme process started
Info: 1. Config check process started
Error: Error: EACCES: permission denied, access './README.md'
Error: Please refer to the documentation
Error: https://github.com/olavoparno/istanbul-badges-readme/blob/master/README.md
Info: 0. Istanbul Badges Readme process finished
which is the expected output (but yeah, we should change that Error: Error:
xD)
As I don't really want to use the table layout but still need the context on which badge is which, using the already present alt
attribute values (e.g. Statements
, Branches
, etc.) as titles for the badges (instead of Coverage
for every badge) would be neat. 🐢
Hey!
I wanna create multiple coverage reports then I need two different markdown templates in README.md. How can I do that?
Example:
X Coverage Report Badges
| Statements | Functions | Lines | Code Quality |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![Statements](https://img.shields.io/badge/Coverage-88.72%25-yellow.svg) | ![Functions](https://img.shields.io/badge/Coverage-91.94%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-89.2%25-yellow.svg) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/46159b0d28324e2485f32409d1b82960)](https://www.codacy.com?utm_source=gitlab.com&utm_medium=referral&utm_content=remoteteam/marketplace-core&utm_campaign=Badge_Grade) |
Y Coverage Report Badges
| Statements | Functions | Lines | Code Quality |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![Statements](https://img.shields.io/badge/Coverage-88.72%25-yellow.svg) | ![Functions](https://img.shields.io/badge/Coverage-91.94%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-89.2%25-yellow.svg) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/46159b0d28324e2485f32409d1b82960)](https://www.codacy.com?utm_source=gitlab.com&utm_medium=referral&utm_content=remoteteam/marketplace-core&utm_campaign=Badge_Grade) |
Wow! This tool is exactly what I needed. Thank you! There is one minor issue on the initial replace. Once I corrected it manually the parser updates it later correct.
Markdown
# Test
![Lines]
Check [here](https://github.com/olavoparno/istanbul-badges-readme) a cool tool.
first run
# Test
![Lines]
https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) a cool tool.
expected
# Test
![Lines](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg)
Check [here](https://github.com/olavoparno/istanbul-badges-readme) a cool tool.
Is your feature request related to a problem? Please describe.
Nope, using it for jest coverage badges and would just like to add the Jest logo in
Describe the solution you'd like
Adding the jest logo into the resulting badge, so it appears like so:
Describe the bug
Not throwing error on CI with --ci argument but only log appear.
Following is my script
"make-badges:ci": "npm run make-badges -- --ci"
To Reproduce
Steps to reproduce the behavior:
Describe the bug
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /home/USER/PROJECT/node_modules/istanbul-badges-readme/lib/index.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/home/USER/PROJECT/node_modules/istanbul-badges-readme/lib/index.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
To Reproduce
npm install
Additional context
1.2.1 works fine locally and in github actions. 1.2.2 fails in both environments.
Node v14.16.0
Npm 6.14.11
Describe the bug
Hello,
On my project I have 2 sub dir
- Matrix
| README.md
| - matrix-back
| | - README.md
| - matrix-front
| | - README.md
Each projects has a README.md.
I have a husky pre-hook in matrix-back who insert coverage into root folder.
If I don't have a statement into my matrix-back/README.md, the message Readme does not contain the needed hashes
is displayed.
The issue is in the method validate.ts doesReadmeFileExist. The param doesn't take --readmeDir
argument.
Additional context
> istanbul-badges-readme --readmeDir="./.."
Info: 0. Istanbul Badges Readme process started
Info: 1. Config check process started
- Readme file exists... ✔️.
- Coverage file exists... ✔️.
- Coverage hashes exist... ✔️.
readmePath= ./README.md
Error: Readme does not contain the needed hashes
Error: Please refer to the documentation
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.