minimal adjustments
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / node_modules / ajv / scripts / jsontests.js
1 "use strict"
2
3 const testSuitePaths = {
4   draft6: "spec/JSON-Schema-Test-Suite/tests/draft6/",
5   draft7: "spec/JSON-Schema-Test-Suite/tests/draft7/",
6   draft2019: "spec/JSON-Schema-Test-Suite/tests/draft2019-09/",
7   draft2020: "spec/JSON-Schema-Test-Suite/tests/draft2020-12/",
8   tests: "spec/tests/",
9   security: "spec/security/",
10   extras: "spec/extras/",
11   async: "spec/async/",
12 }
13
14 const glob = require("glob")
15 const fs = require("fs")
16
17 for (const suite in testSuitePaths) {
18   const p = testSuitePaths[suite]
19   const files = glob.sync(`${p}{**/,}*.json`)
20   if (files.length === 0) {
21     console.error(`Missing folder ${p}\nTry: git submodule update --init\n`)
22     process.exit(1)
23   }
24   const code = files
25     .map((f) => {
26       const name = f.replace(p, "").replace(/\.json$/, "")
27       const testPath = f.replace(/^spec/, "..")
28       return `\n  {name: "${name}", test: require("${testPath}")},`
29     })
30     .reduce((list, f) => list + f)
31   fs.writeFileSync(`./spec/_json/${suite}.js`, `module.exports = [${code}\n]\n`)
32 }