Nitroglycerin Pickle Machine
    Wondering what’s next for npm?Check out our public roadmap! »

    istanbul-badges-readme

    1.2.1 • Public • Published

    traffic

    Istanbul Badges Readme

    Creates README badges from istanbul coverage report

    Statements Branches Functions Lines
    Statements Branches Functions Lines

    Current Version: 1.2.0

    Table of Contents


    Markup example (paste it anywhere in your README.md)

    | Statements                  | Branches                | Functions                 | Lines                |
    | --------------------------- | ----------------------- | ------------------------- | -------------------- |
    | ![Statements](#statements#) | ![Branches](#branches#) | ![Functions](#functions#) | ![Lines](#lines#)    |
    • The table is optional, the only markup that matters are the following:
    1. ![Statements](#statements#)
    2. ![Branches](#branches#)
    3. ![Functions](#functions#)
    4. ![Lines](#lines#)

    Running example

    Example


    Requirements

    • 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 or jestconfig.json as shown below:
      "coverageReporters": ["json-summary"]

    Installation

      npm i -D istanbul-badges-readme

    Usage

    • 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",
    }

    Usage as a part of your githooks

    • 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.
    1. Install Husky.
      npm install -D husky
    1. Add your pre-commit script:
      "husky": {
        "hooks": {
          "pre-commit": "npm run test && istanbul-badges-readme && git add 'README.md'"
        }
      }
    1. 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!

    See more examples

    Examples folder


    Contributors

    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!


    License

    Istanbul Badges Readme is MIT licensed.

    Install

    npm i istanbul-badges-readme

    DownloadsWeekly Downloads

    2,891

    Version

    1.2.1

    License

    MIT

    Unpacked Size

    21.6 kB

    Total Files

    12

    Last publish

    Collaborators

    • avatar