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)

21 lines 1.11 kB
const path = require('path'); const fs = require('fs/promises'); const types = require("../constants/types"); const { detectType } = require("../helpers/detectType") const { packageManagerProviders } = require("../constants/provierConstants"); const { readCacheFile } = require('../helpers/readCacheFile'); exports.generate = async function () { const { type } = await detectType(packageManagerProviders, "Package manager"); switch (type) { case types.NPM: let packagejson = await readCacheFile(path.resolve(process.cwd(), "package.json")); packagejson = JSON.parse(packagejson); return [ `[![min size](https://img.shields.io/bundlephobia/min/${packagejson.name})](https://bundlephobia.com/result?p=${packagejson.name})`, `[![mingzip size](https://img.shields.io/bundlephobia/minzip/${packagejson.name})](https://bundlephobia.com/result?p=${packagejson.name})` ].join("\n") default: console.error("Could not find any size related configuration. Skipping it...") return ''; } }