type-coverage
Advanced tools
Comparing version 1.4.6 to 1.5.0
@@ -25,8 +25,17 @@ "use strict"; | ||
suppressError = argv.suppressError; | ||
const { correctCount, totalCount, anys } = await core_1.lint(argv.p || argv.project || '.', argv.detail, argv.debug); | ||
for (const { file, line, character, text } of anys) { | ||
console.log(`${path.resolve(process.cwd(), file)}:${line + 1}:${character + 1}: ${text}`); | ||
const { correctCount, totalCount, anys } = await core_1.lint(argv.p || argv.project || '.', true, argv.debug); | ||
const percent = Math.round(10000 * correctCount / totalCount) / 100; | ||
const atLeast = await getAtLeast(argv); | ||
const failed = atLeast && percent < atLeast; | ||
if (argv.detail || failed) { | ||
for (const { file, line, character, text } of anys) { | ||
console.log(`${path.resolve(process.cwd(), file)}:${line + 1}:${character + 1}: ${text}`); | ||
} | ||
} | ||
const percent = Math.round(10000 * correctCount / totalCount) / 100; | ||
console.log(`${correctCount} / ${totalCount} ${percent.toFixed(2)}%`); | ||
if (failed) { | ||
throw new Error(`The type coverage rate(${percent.toFixed(2)}%) is lower than the target(${atLeast}%). \nYou can add '--detail' or use VSCode plugin to show detailed informations.`); | ||
} | ||
} | ||
async function getAtLeast(argv) { | ||
let atLeast; | ||
@@ -43,5 +52,3 @@ const packageJsonPath = path.resolve(process.cwd(), 'package.json'); | ||
} | ||
if (atLeast && percent < atLeast) { | ||
throw new Error(`The type coverage rate(${percent.toFixed(2)}%) is lower than the target(${atLeast}%). \nYou can add '--detail' or use VSCode plugin to show detailed informations.`); | ||
} | ||
return atLeast; | ||
} | ||
@@ -48,0 +55,0 @@ executeCommandLine().then(() => { |
{ | ||
"name": "type-coverage", | ||
"version": "1.4.6", | ||
"version": "1.5.0", | ||
"description": "A CLI tool to check type coverage for typescript code", | ||
@@ -5,0 +5,0 @@ "main": "dist/core.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63459
1084