summaryrefslogtreecommitdiff
path: root/dev/build-libs.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-19 00:33:38 -0500
committerGitHub <noreply@github.com>2023-12-19 05:33:38 +0000
commit1ced9aafc00c10992bab8bd3f1b6b1397f05b7b9 (patch)
tree305bb2b3bfc7fc3b051ee1cd3d1c35f442af0de4 /dev/build-libs.js
parent5f96276fda93dcad39f2165fd3c8d890aa5f9be5 (diff)
Make JSON.parse usage safer (#373)
* Make JSON.parse usage safer * Fix any type * Add readResponseJson * Use readResponseJson * Additional updates * Rename files * Add types
Diffstat (limited to 'dev/build-libs.js')
-rw-r--r--dev/build-libs.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/dev/build-libs.js b/dev/build-libs.js
index a992f20a..10720010 100644
--- a/dev/build-libs.js
+++ b/dev/build-libs.js
@@ -22,6 +22,7 @@ import esbuild from 'esbuild';
import fs from 'fs';
import path from 'path';
import {fileURLToPath} from 'url';
+import {parseJson} from './json.js';
const dirname = path.dirname(fileURLToPath(import.meta.url));
const extDir = path.join(dirname, '..', 'ext');
@@ -61,7 +62,11 @@ export async function buildLibs() {
const schemaDir = path.join(extDir, 'data/schemas/');
const schemaFileNames = fs.readdirSync(schemaDir);
- const schemas = schemaFileNames.map((schemaFileName) => JSON.parse(fs.readFileSync(path.join(schemaDir, schemaFileName), {encoding: 'utf8'})));
+ const schemas = schemaFileNames.map((schemaFileName) => {
+ /** @type {import('ajv').AnySchema} */
+ const result = parseJson(fs.readFileSync(path.join(schemaDir, schemaFileName), {encoding: 'utf8'}));
+ return result;
+ });
const ajv = new Ajv({
schemas,
code: {source: true, esm: true},