(
/** @type {string} */ filepath,
/** @type {string} */ schemaFilepath,
)
| 1724 | } |
| 1725 | |
| 1726 | async function assertFileValidatesAgainstSchema( |
| 1727 | /** @type {string} */ filepath, |
| 1728 | /** @type {string} */ schemaFilepath, |
| 1729 | ) { |
| 1730 | const [data, schemaJson] = await Promise.all([ |
| 1731 | fs.readFile(filepath, 'utf-8').then((data) => jsoncParser.parse(data)), |
| 1732 | readJsonFile(schemaFilepath), |
| 1733 | ]) |
| 1734 | |
| 1735 | const ajv = new AjvDraft06And07({ |
| 1736 | strict: true, |
| 1737 | }) |
| 1738 | addFormats(ajv) |
| 1739 | |
| 1740 | if (ajv.validate(schemaJson, data)) { |
| 1741 | console.info(`✔️ ${path.basename(filepath)} validates against its schema`) |
| 1742 | } else { |
| 1743 | printSchemaValidationErrorAndExit(filepath, schemaFilepath, ajv.errors) |
| 1744 | } |
| 1745 | } |
| 1746 | |
| 1747 | async function assertSchemaHasValidSchemaField( |
| 1748 | /** @type {SchemaFile} */ schema, |
no test coverage detected