Skip to content

Commit

Permalink
Merge pull request #6900 from wenzhixin/feature/6450
Browse files Browse the repository at this point in the history
Improved the check api tools to check the default option
  • Loading branch information
fish-fly authored Jul 15, 2023
2 parents fe19984 + e98b976 commit db20616
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tools/check-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,18 @@ class API {
md[item.split('\n')[0]] = item
}

const mds = Object.keys(md)
console.log('-------------------------')
console.log(`Checking file: ${file}`)
console.log('-------------------------')

const noDefaults = Object.keys(md).filter(it => !this.options.includes(it))

if (noDefaults.length) {
errorSum += noDefaults.length
console.log(chalk.red(`No default option was found for "${noDefaults.join(', ')}", should the documentation be removed!`))
return
}

for (const [i, key] of this.options.entries()) {
try {
if (md[key]) {
Expand Down Expand Up @@ -92,14 +103,11 @@ class API {

errorSum += errors.length
if (errors.length > 0) {
console.log('-------------------------')
console.log(`Checking file: ${file}`)
console.log('-------------------------')

errors.forEach((error) => {
console.log(error)
})
}

fs.writeFileSync(file, outLines.join('## '))
}
}
Expand Down

0 comments on commit db20616

Please sign in to comment.