Skip to content

Commit

Permalink
fix: error count more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenQingchuan committed Sep 20, 2022
1 parent b9634b5 commit 5ceb323
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/inquirer-file-tree-selection-prompt/index.ts
Expand Up @@ -208,7 +208,7 @@ class FileTreeSelectionPrompt extends Base<
rootNode.open = true
this.active = this.active || rootNode.children?.[0]
if (this.active) {
this.prepareChildren(this.active)
await this.prepareChildren(this.active)
}
this.render()
}
Expand Down
8 changes: 6 additions & 2 deletions src/index.ts
Expand Up @@ -38,14 +38,18 @@ ${chalk.blue(`error TS${errInfo.errCode}`)}: ${errInfo.errMsg}
function isOptionPathContained({
root,
optionPath,
needSepSuffix = false,
}: {
root: string
optionPath: string
needSepSuffix?: boolean
}) {
return (relativeToRoot: string) => {
const absPath = path.join(root, relativeToRoot)
// Appending '/' is aimed to avoid last path unit of a directory is optionPath's sub-string
const isAbsPathIncludeOptionPath = absPath.includes(`${optionPath}/`)
const isAbsPathIncludeOptionPath = absPath.startsWith(
`${optionPath}${needSepSuffix && !isFilePath(optionPath) ? path.sep : ''}`
)
return isAbsPathIncludeOptionPath
}
}
Expand All @@ -66,7 +70,7 @@ function createOptionPathTransformer({
? chalk.blue
: chalk.italic.bold.yellowBright
const errsCountInPath = [...rawErrsMap.keys()]
.filter(isOptionPathContained({ root, optionPath }))
.filter(isOptionPathContained({ root, optionPath, needSepSuffix: true }))
.reduce((prev, hasErrPath) => {
return prev + (rawErrsMap.get(hasErrPath)?.length ?? 0)
}, 0)
Expand Down

0 comments on commit 5ceb323

Please sign in to comment.