UNPKG

git-auto-badger

Version:

A npm cli tool that reads your package.json/project metadata and git config and connects your readme with multiple badge providers (shields.io, badgen.net etc)

18 lines 1.11 kB
const types = require("../constants/types"); const { detectRepoUrl } = require("../helpers/detectRepoUrl"); const { detectType } = require("../helpers/detectType") const { parseRepoUrl } = require("../helpers/parseRepoUrl"); const { coverageProviders } = require("../constants/provierConstants"); exports.generate = async function () { const [{ type }, repoUrl] = await Promise.all([detectType(coverageProviders, "COVERAGE"), detectRepoUrl()]); const { repoOwner, repoName } = parseRepoUrl(repoUrl); switch (type) { case types.CODECOV: return `[![Code coverage](https://img.shields.io/codecov/c/github/${repoOwner}/${repoName}.svg?style=flat-square)](https://codecov.io/github/${repoOwner}/${repoName})` case types.COVERALLS: return `[![Code coverage](https://img.shields.io/coveralls/github/${repoOwner}/${repoName}.svg?style=flat-square)](https://coveralls.io/github/${repoOwner}/${repoName}?branch=master)` default: console.error("Could not find any code coverage related configuration. Skipping it..."); return ''; } }