git-auto-badger
Version:
Add badges to your project markdown in 2 seconds
22 lines (20 loc) • 1.38 kB
JavaScript
const { detectRepoUrl } = require("../helpers/detectRepoUrl");
const { parseRepoUrl } = require("../helpers/parseRepoUrl");
const { badgeTypes } = require("../constants/types");
exports.generate = async function ({ exclude }) {
const repoUrl = await detectRepoUrl();
const { repoOwner, repoName } = parseRepoUrl(repoUrl);
const allContributersBadge = exclude.includes(badgeTypes.ALL_CONTRIBUTERS)
? ``
: `[](https://github.com/${repoOwner}/${repoName}/graphs/contributors)`;
const codeOfConduct = exclude.includes(badgeTypes.CODE_OF_CONDUCT)
? ``
: `[](https://github.com/${repoOwner}/${repoName}/blob/master/CODE_OF_CONDUCT.md)`;
const starsBadge = exclude.includes(badgeTypes.GH_STAR)
? ``
: `[](https://github.com/${repoOwner}/${repoName}/stargazers)`;
const forkBadge = exclude.includes(badgeTypes.GH_FORK)
? ``
: `[](https://github.com/${repoOwner}/${repoName}/fork)`;
return [allContributersBadge, codeOfConduct, starsBadge, forkBadge];
};