Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detect-readme-badges

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-readme-badges

Scans a repository's readme file, searching for badges

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

detect-readme-badges

Scans a repository readme file, searching for badges.

NPM version Build Status Coverage Status Dependency status Dev Dependency status Greenkeeper badge

Usage

detectReadmeBadges(readme) -> Array

Given a readme file (in string), detectReadmeBadges returns the array of badges found. Example:

const detectReadmeBadges = require('detect-readme-badges');
const badges = detectReadmeBadges(`
    ...

    > Simplified HTTP/HTTPS requests

    [![Build Status](https://travis-ci.org/sindresorhus/got.svg?branch=master)](https://travis-ci.org/sindresorhus/got) [![Coverage Status](https://coveralls.io/repos/sindresorhus/got/badge.svg?service=github&branch=master)](https://coveralls.io/github/sindresorhus/got?branch=master) [![Downloads](https://img.shields.io/npm/dm/got.svg)](https://npmjs.com/got)

    A nicer interface to the built-in ['http'](http://nodejs.org/api/http.html) module.

    ...
`)

// badges
[
    {
        urls: {
            original: 'https://travis-ci.org/sindresorhus/got.svg?branch=master',
            service: 'https://api.travis-ci.org/sindresorhus/got.svg?branch=master',
            shields: 'https://img.shields.io/travis/sindresorhus/got/master.svg',
            content: 'https://img.shields.io/travis/sindresorhus/got/master.json',
        },
        info: { service: 'travis', type: 'build', modifiers: { branch: 'master' } },
    },
    {
        urls: {
            original: 'https://coveralls.io/repos/sindresorhus/got/badge.svg?branch=master',
            service: 'https://coveralls.io/repos/sindresorhus/got/badge.svg?branch=master',
            shields: 'https://img.shields.io/coveralls/sindresorhus/got/master.svg',
            content: 'https://img.shields.io/coveralls/sindresorhus/got/master.json',
        },
        info: { service: 'coveralls', type: 'coverage', modifiers: { branch: 'master' } },
    },
    {
        urls: {
            original: 'https://img.shields.io/npm/dm/got.svg',
            shields: 'https://img.shields.io/npm/dm/got.svg',
            content: 'https://img.shields.io/npm/dm/got.json' },
        info: { service: 'npm', type: 'downloads', modifiers: { type: 'dm' } },
    },
]
badge.urls

urls.original the original matched url.

urls.service the service url.

urls.shields the shields.io equivalent url.

urls.content the shields.io url to extract a json of the badge's "value".

badge.info

Information extracted from the badge url.

info.type type of the badge. Available types are build, coverage, downloads, version, dependencies and misc.

info.service is the service that provides the badge. Available services are coveralls, david, npm (shields.io or nodei.co), travis and gitter.

info.modifiers are the badge modifiers that alter the interpretation of the repo/package depending on the service.

Tests

$ npm test $ npm test-cov to get coverage report

License

Released under the MIT License.

Keywords

FAQs

Package last updated on 05 Nov 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc