(schemaFile: string, files: string[])
| 41 | }) |
| 42 | .join('; ') |
| 43 | } |
| 44 | |
| 45 | function validateFiles(schemaFile: string, files: string[]): void { |
| 46 | const ajv = new Ajv({ allErrors: true, strict: false }) |
| 47 | const validate = ajv.compile(readJson(schemaFile) as AnySchema) |
| 48 | let errors = 0 |
| 49 | |
| 50 | for (const file of files) { |
| 51 | const data = readYaml(file) |
| 52 | if (validate(data)) { |
| 53 | console.log(`${path.relative(process.cwd(), file)} valid`) |
| 54 | continue |
| 55 | } |
| 56 | |
| 57 | errors += 1 |
| 58 | console.error(`${path.relative(process.cwd(), file)} invalid`) |
| 59 | console.error(formatErrors(validate.errors ?? [])) |
| 60 | } |
| 61 | |
| 62 | if (errors > 0) { |
| 63 | process.exitCode = 1 |
| 64 | } |
| 65 | } |
| 66 |
no test coverage detected