forked from mirnes-cajlakovic/openai-schemas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (32 loc) · 961 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require('fs')
const path = require('path')
const schemasIndex = []
const schemasPath = path.join(__dirname, 'schemas')
fs.readdirSync(schemasPath)
.filter((dir) => {
return fs.statSync(path.join(schemasPath, dir)).isDirectory()
})
.map((dir) => {
const dirPath = path.join(schemasPath, dir)
fs.readdirSync(dirPath)
.filter((file) => {
return path.extname(file) === '.json'
})
.map((file) => {
const name = path.basename(file, path.extname(file))
schemasIndex.push({ name, dir, src: path.join('./schemas/', dir, name) })
})
})
const modules = {
Parse: require('./src/Parse'),
Scrape: require('./src/Scrape'),
Update: require('./src/Update'),
schemas: {}
}
for (const schema of schemasIndex) {
if (!modules.schemas[schema.dir]) {
modules.schemas[schema.dir] = {}
}
modules.schemas[schema.dir][schema.name] = require('./' + schema.src)
}
module.exports = modules