-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
43 lines (35 loc) · 906 Bytes
/
index.ts
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
37
38
39
40
41
42
43
/**
* @license
* Copyright 2022 Open Ag Data Alliance
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
import path from 'node:path';
import url from 'node:url';
import { glob } from 'glob';
import { importSchema } from './utils.cjs';
const dirname = path.dirname(url.fileURLToPath(import.meta.url));
export const schemasDirectory = dirname;
export const schemas = await glob('*.schema.{c,m,}js', {
cwd: dirname,
posix: true,
dotRelative: true,
matchBase: true,
});
/**
* Load all the schemas
*/
async function* loadAllFormats() {
for await (const s of schemas) {
const schema = await importSchema(s);
const key = s.replace(/\.[cm]?[jt]s$/, '.json');
yield {
key,
path: path.join(dirname, key),
schema,
};
}
}
export default loadAllFormats;