Skip to content

Commit fda683b

Browse files
clydinalexeagle
authored andcommitted
build: only generate types for actual JSON schemas
1 parent 7439fab commit fda683b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/build-schema.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,15 @@ export default async function(
6060
}
6161
const content = fs.readFileSync(fileName, 'utf-8');
6262

63-
const json = JSON.parse(content);
64-
if (!json.$schema) {
65-
// Skip non-schema files.
63+
let json;
64+
try {
65+
json = JSON.parse(content);
66+
if (typeof json.$schema !== 'string' || !json.$schema.startsWith('http://json-schema.org/')) {
67+
// Skip non-schema files.
68+
continue;
69+
}
70+
} catch {
71+
// malformed or JSON5
6672
continue;
6773
}
6874
const tsContent = await quicktypeRunner.generate(fileName);

0 commit comments

Comments
 (0)