Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@collaborne/github-badges

Package Overview
Dependencies
Maintainers
6
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@collaborne/github-badges - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

dist/bin/create-coverage-badges.d.ts

10

dist/create-coverage-badges.js

@@ -34,2 +34,3 @@ "use strict";

const mkdirp_1 = __importDefault(require("mkdirp"));
const constants_1 = require("./constants");
const reportKeys = [

@@ -51,9 +52,12 @@ 'lines',

};
const DEFAULT_INPUT_PATH = path.resolve(__dirname, '..', 'coverage', 'coverage-summary.json');
const DEFAULT_OUTPUT_PATH = path.resolve(__dirname, '..', 'coverage');
const DEFAULT_INPUT_PATH = path.resolve('coverage', 'coverage-summary.json');
const DEFAULT_OUTPUT_PATH = path.resolve('coverage');
/** Create coverage badges (svg picture icons) based on icons from shields.io */
function createCoverageBadge(inputPath = DEFAULT_INPUT_PATH, outputPath = DEFAULT_OUTPUT_PATH) {
console.group(constants_1.FgBlue, 'Using these paths for coverage badges:');
console.log(`${constants_1.FgCyan}coverage-summary.json: ${constants_1.FgGreen}${inputPath}`);
console.log(`${constants_1.FgCyan}output folder for svg's: ${constants_1.FgGreen}${outputPath}`);
const getBadge = (report, key) => {
if (!(report && report.total && report.total[key])) {
throw new Error('malformed coverage report');
throw new Error(`${constants_1.FgRed} Malformed coverage report`);
}

@@ -60,0 +64,0 @@ const coverage = !report.total[key] || typeof report.total[key].pct !== 'number'

{
"name": "@collaborne/github-badges",
"version": "0.0.2",
"version": "0.0.3",
"description": "Github SVG badges for repositories",

@@ -9,2 +9,5 @@ "author": "Collaborne",

"source": "src/index.ts",
"bin": {
"create-coverage-badges": "dist/bin/create-coverage-badges.js"
},
"scripts": {

@@ -11,0 +14,0 @@ "build": "npm run lint:ts && npm run build:ts --",

@@ -13,2 +13,4 @@ # @collaborne/github-badges

- import in JS/TS files
```ts

@@ -31,6 +33,27 @@ import { createCoverageBadge } from '@collaborne/github-badges'

```
- as a script in **package.json**
```json
...
scripts :{
...
"predeploy:coverage-badges": "create-coverage-badges"
...
}
...
```
By default uses for coverage report input: **coverage/coverage-summary.json** , and outputs created svg's into the same **coverage** folder.
Flags for input: `--i` or `-inputPath`
Flags for output: `--o`, `--d`, `-outputPath` or `-dist`
## License
(c) 2023 Collaborne B.V. All rights reserved.

@@ -7,2 +7,4 @@ import { readFile, writeFile } from 'fs';

import { FgBlue, FgCyan, FgGreen, FgRed } from './constants';
interface ReportData {

@@ -43,11 +45,5 @@ total: number;

const DEFAULT_INPUT_PATH = path.resolve(
__dirname,
'..',
'coverage',
'coverage-summary.json',
);
const DEFAULT_INPUT_PATH = path.resolve('coverage', 'coverage-summary.json');
const DEFAULT_OUTPUT_PATH = path.resolve('coverage');
const DEFAULT_OUTPUT_PATH = path.resolve(__dirname, '..', 'coverage');
/** Create coverage badges (svg picture icons) based on icons from shields.io */

@@ -58,5 +54,8 @@ export function createCoverageBadge(

) {
console.group(FgBlue, 'Using these paths for coverage badges:');
console.log(`${FgCyan}coverage-summary.json: ${FgGreen}${inputPath}`);
console.log(`${FgCyan}output folder for svg's: ${FgGreen}${outputPath}`);
const getBadge = (report: TotalReport, key: keyof Report) => {
if (!(report && report.total && report.total[key])) {
throw new Error('malformed coverage report');
throw new Error(`${FgRed} Malformed coverage report`);
}

@@ -63,0 +62,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc