Custom Badge URLs
Creates Shields.io badge URLs for custom badges.
Installation
$ npm install shields-badge-url-custom
Usage
var urls = ;
urls( opts )
Creates Shields.io badge URLs for custom badges.
var opts ='label': 'build''status': 'passing''color': 'brightgreen';var out = ;/*{"image": "https://img.shields.io/badge/build-passing-brightgreen.svg?style=flat"}*/
The function
accepts the following options
:
- label: (required) badge label.
- status: (required) badge status.
- color: (required) badge color. A color may be either a named (e.g.,
brightgreen
,green
,yellow
,red
, etc) or HEX (e.g.,474747
,eeeeee
, etc). - style: badge style. Default:
flat
. - format: badge format. Default:
svg
. - logo: badge logo (>= 14px high and provided as a data URI).
- width: badge width (pixels).
- llink: left side link. (note: must be provided with a right side link.)
- rlink: right side link. (note: must be provided with a left side link.)
Examples
var mnames = ;var fnames = ;var randc = ;var urls = ;// Badges for everyone! Create random personalized greeting badges...var badge;var len;var idx;var n;var i;len = mnameslength + fnameslength;for i = 0; i < len; i++if len%2 === 0idx = Math;n = fnames idx ;elseidx = Math;n = mnames idx ;badge =;console;
To run the example code from the top-level application directory,
$ node ./examples/index.js
CLI
Installation
To use the module as a general utility, install the module globally
$ npm install -g shields-badge-url-custom
Usage
Usage: shields-custom --label=<label> --status=<status> --color=<color> [options]Options:-h, --help Print this message.-V, --version Print the package version.--label label Badge label.--status status Badge status.--color color Badge color.--style style Badge style. Default: 'flat'.--format format Badge format. Default: 'svg'.--logo logo Badge logo.--width width Badge logo width (pixels).--llink link Left side badge link.--rlink link Right side badge link.
Examples
$ shields-custom --label=beep --status=boop --color="474747"# => {"image":"https://img.shields.io/badge/beep-boop-474747.svg?style=flat"}
Tests
Unit
This repository uses tape for unit tests. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
Browser Support
This repository uses Testling for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:
$ make test-browsers
To view the tests in a local web browser,
$ make view-browser-tests
License
Copyright
Copyright © 2016. Athan Reines.