type-coverage
Advanced tools
Comparing version 2.17.5 to 2.18.0
@@ -36,2 +36,3 @@ "use strict"; | ||
--show-relative-path boolean? show relative path in detail message | ||
--history-file string? file name where history is saved | ||
`); | ||
@@ -50,3 +51,3 @@ } | ||
} | ||
const { atLeast, debug, detail, enableCache, ignoreCatch, ignoreFiles, ignoreUnread, is, project, strict, update, ignoreNested, ignoreAsAssertion, ignoreTypeAssertion, ignoreNonNullAssertion, showRelativePath, } = await getTarget(argv); | ||
const { atLeast, debug, detail, enableCache, ignoreCatch, ignoreFiles, ignoreUnread, is, project, strict, update, ignoreNested, ignoreAsAssertion, ignoreTypeAssertion, ignoreNonNullAssertion, showRelativePath, historyFile, } = await getTarget(argv); | ||
const { correctCount, totalCount, anys } = await type_coverage_core_1.lint(project, { | ||
@@ -78,2 +79,5 @@ debug, | ||
} | ||
if (historyFile) { | ||
await saveHistory(+percentString, historyFile); | ||
} | ||
if (atLeastFailed) { | ||
@@ -126,2 +130,3 @@ throw new Error(`The type coverage rate(${percentString}%) is lower than the target(${atLeast}%).`); | ||
const showRelativePath = getArgOrCfgVal(['show-relative-path', 'showRelativePath']); | ||
const historyFile = getArgOrCfgVal(['history-file', 'historyFile']); | ||
return { | ||
@@ -144,2 +149,3 @@ atLeast, | ||
showRelativePath, | ||
historyFile, | ||
}; | ||
@@ -162,2 +168,19 @@ } | ||
} | ||
async function saveHistory(percentage, historyFile) { | ||
if (historyFile) { | ||
const historyFilePath = path.resolve(process.cwd(), historyFile); | ||
if (await existsAsync(historyFilePath)) { | ||
const date = new Date().toISOString(); | ||
const historyFile = JSON.parse((await readFileAsync(historyFilePath)).toString()); | ||
historyFile[date] = percentage; | ||
await writeFileAsync(historyFilePath, JSON.stringify(historyFile, null, 2) + '\n'); | ||
} | ||
else { | ||
const date = new Date().toISOString(); | ||
const historyFile = {}; | ||
historyFile[date] = percentage; | ||
await writeFileAsync(historyFilePath, JSON.stringify(historyFile, null, 2) + '\n'); | ||
} | ||
} | ||
} | ||
executeCommandLine().then(() => { | ||
@@ -164,0 +187,0 @@ console.log('type-coverage success.'); |
{ | ||
"name": "type-coverage", | ||
"version": "2.17.5", | ||
"version": "2.18.0", | ||
"description": "A CLI tool to check type coverage for typescript code", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/plantain-00/type-coverage.git", |
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
8494
191