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/",
9 security: "spec/security/",
10 extras: "spec/extras/",
14 const glob = require("glob")
15 const fs = require("fs")
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`)
26 const name = f.replace(p, "").replace(/\.json$/, "")
27 const testPath = f.replace(/^spec/, "..")
28 return `\n {name: "${name}", test: require("${testPath}")},`
30 .reduce((list, f) => list + f)
31 fs.writeFileSync(`./spec/_json/${suite}.js`, `module.exports = [${code}\n]\n`)