All files index.ts

77.27% Statements 17/22
75% Branches 6/8
100% Functions 3/3
77.27% Lines 17/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                        1x                         1x         1x 1x       1x         1x 1x 1x 1x 1x 1x 1x       1x 1x 1x 1x 1x  
import minimist, { ParsedArgs } from 'minimist';
import { create } from './create';
import { BadgeOption } from './badges';
 
export interface RunArgvs extends ParsedArgs, Partial<BadgeOption> {
  source?: string;
  version?: string;
  output?: string;
  jsonPath?: string;
}
 
export default function run() {
  const argvs: RunArgvs = minimist(process.argv.slice(2), {
    alias: {
      help: 'h',
      source: 's',
      output: 'o',
    },
    default: {
      style: 'classic',
      source: 'coverage/coverage-summary.json',
      output: 'coverage/badges.svg',
      jsonPath: 'total.statements.pct',
    },
  });
  Iif (argvs.h || argvs.help) {
    cliHelp()
    exampleHelp()
    return;
  }
  const { version } = require('../package.json');
  Iif (argvs.v || argvs.version) {
    console.log(`\n coverage-badges-cli v${version}\n`);
    return;
  }
  create(argvs);
}
 
 
export function cliHelp() {
  console.log('\n  Usage: coverage-badges [options] [--help|h]');
  console.log('\n  Options:\n');
  console.log('    --version, -v ', 'Show version number');
  console.log('    --help, -h    ', 'Displays help information.');
  console.log('    --output, -o  ', 'Output directory.');
  console.log('    --source, -s  ', 'The path of the target file "coverage-summary.json".');
  console.log('    --style       ', 'Badges style: flat, flat-square.');
}
 
export function exampleHelp() {
  console.log('\n  Example:\n');
  console.log('    \x1b[35mnpm\x1b[0m coverage-badges-cli \x1b[33m--output\x1b[0m coverage/badges.svg');
  console.log('    \x1b[35mnpm\x1b[0m coverage-badges-cli \x1b[33m--style\x1b[0m plastic');
  console.log('    \x1b[35mnpm\x1b[0m coverage-badges-cli \x1b[33m--source\x1b[0m coverage/coverage-summary.json');
  console.log('\n');
}