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)
23 lines (22 loc) • 1.16 kB
JavaScript
const types = require("../constants/types");
const { detectRepoUrl } = require("../helpers/detectRepoUrl");
const { parseRepoUrl } = require("../helpers/parseRepoUrl");
exports.generate = async function ({ communityProvider, communityId, communityServerUrl }) {
if (!communityProvider) {
return ``;
}
const repoUrl = await detectRepoUrl();
const { repoOwner, repoName } = parseRepoUrl(repoUrl);
const community = communityProvider.toUpperCase();
switch (community) {
case types.DISCORD:
return `[](${communityServerUrl})`;
case types.SPECTRUM:
return `[](https://spectrum.chat/${communityId})`
case types.GITTER:
return `[](https://gitter.im/${communityId})`
default:
console.error("Could not find any community related configuration. Skipping it...");
return '';
}
}