浏览代码

Merge pull request #6900 from wenzhixin/feature/6450

Improved the check api tools to check the default option
飞鱼 2 年之前
父节点
当前提交
db20616a91
共有 1 个文件被更改,包括 13 次插入5 次删除
  1. 13 5
      tools/check-api.js

+ 13 - 5
tools/check-api.js

@@ -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]) {
@@ -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('## '))
   }
 }