https://github.com/ppvg/node-coverage-badge
Generate fancy code coverage badges for your node project.
https://github.com/ppvg/node-coverage-badge
Last synced: about 1 month ago
JSON representation
Generate fancy code coverage badges for your node project.
- Host: GitHub
- URL: https://github.com/ppvg/node-coverage-badge
- Owner: ppvg
- License: bsd-2-clause
- Created: 2013-06-17T16:37:33.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-05-26T10:04:19.000Z (almost 10 years ago)
- Last Synced: 2025-03-25T13:01:47.398Z (about 2 months ago)
- Language: JavaScript
- Size: 197 KB
- Stars: 7
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Generate fancy code coverage badges! Does what it says on the tin.
  
Works like this:
$ node coverage-badge 95 coverage.png
... or like this:
var fs = require('fs');
var badge = require('coverage-badge');var coverage = /* read coverage from JSON or whatever */;
var file = fs.createWriteStream('coverage.png');badge(coverage).pipe(file);
Tie it in with build tool and let your continuous integration tool call that build step and archive the image.
Example
-------An example: [node-aether](https://github.com/PPvG/node-aether) uses Drone.io as CI server and `slake` as build tool. The relevant build step runs `jscoverage` to instrument, then runs `mocha` to generate a JSON code coverage report, and then uses that to generate the coverage badge. That last bit looks like this (rewritten from the original LiveScript):
var badge = require('coverage-badge');
task 'cov-badge', function() {
/* [run jscoverage...] */
/* [run mocha...] */
mocha.on('close'), function() {
var json = require('./coverage.json');
var file = fs.createWriteStream('./coverage.png');
badge(json.coverage).pipe(file);
}
}At each build, Drone.io runs these commands:
sudo apt-get install jscoverage
slake cov-badge... and then saves `./coverage.png` as a **build artefact**. The image can then be found under the Downloads tab. The result:
[](https://github.com/PPvG/node-aether)Visual theme
------------Currently it pretty much mimics the look of the Drone.io badge. Other styles may be added in the future.
Installation
------------npm install coverage-badge
License
-------Simplified BSD (2-clause).