jaz-ts-utils
Advanced tools
Comparing version 7.7.1 to 7.8.0
@@ -5,2 +5,3 @@ import { Static, TObject } from "@sinclair/typebox"; | ||
filePath?: string; | ||
config?: Static<T>; | ||
schema: T; | ||
@@ -7,0 +8,0 @@ }; |
@@ -12,2 +12,3 @@ "use strict"; | ||
filePath: "config.json", | ||
config: undefined, | ||
}; | ||
@@ -26,4 +27,10 @@ const ajv = new ajv_1.default({ | ||
const validator = ajv.compile(finalOptions.schema); | ||
const configFile = await fs_1.default.promises.readFile(finalOptions.filePath, { encoding: "utf-8" }); | ||
const config = JSON.parse(configFile); | ||
let config; | ||
if (finalOptions.config) { | ||
config = finalOptions.config; | ||
} | ||
else { | ||
const configFile = await fs_1.default.promises.readFile(finalOptions.filePath, { encoding: "utf-8" }); | ||
config = JSON.parse(configFile); | ||
} | ||
const isValid = validator(config); | ||
@@ -30,0 +37,0 @@ if (!isValid) { |
{ | ||
"name": "jaz-ts-utils", | ||
"version": "7.7.1", | ||
"version": "7.8.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
56278
887