From fda683b8743700b8fdc1ff7a4df1ef38b5a1782c Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 19 Mar 2019 10:21:51 -0400 Subject: [PATCH] build: only generate types for actual JSON schemas --- scripts/build-schema.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/build-schema.ts b/scripts/build-schema.ts index 3587d0584c..a5d64ae462 100644 --- a/scripts/build-schema.ts +++ b/scripts/build-schema.ts @@ -60,9 +60,15 @@ export default async function( } const content = fs.readFileSync(fileName, 'utf-8'); - const json = JSON.parse(content); - if (!json.$schema) { - // Skip non-schema files. + let json; + try { + json = JSON.parse(content); + if (typeof json.$schema !== 'string' || !json.$schema.startsWith('http://json-schema.org/')) { + // Skip non-schema files. + continue; + } + } catch { + // malformed or JSON5 continue; } const tsContent = await quicktypeRunner.generate(fileName);