2021-10-25 21:13:10 +02:00
|
|
|
/**
|
|
|
|
* @fileoverview
|
|
|
|
* CLI tool to run jsonschema on the simple-icons.json data file.
|
|
|
|
*/
|
2021-02-19 16:19:22 +02:00
|
|
|
|
2023-08-08 06:38:52 +02:00
|
|
|
import process from 'node:process';
|
2021-12-25 16:22:56 +02:00
|
|
|
import { Validator } from 'jsonschema';
|
2023-08-08 06:38:52 +02:00
|
|
|
import { getIconsData } from '../../sdk.mjs';
|
2023-04-19 15:23:13 +02:00
|
|
|
import { getJsonSchemaData } from '../utils.js';
|
2021-12-25 16:22:56 +02:00
|
|
|
|
2022-09-28 04:11:27 +02:00
|
|
|
const icons = await getIconsData();
|
2023-08-08 06:38:52 +02:00
|
|
|
const schema = await getJsonSchemaData();
|
2021-10-25 21:13:10 +02:00
|
|
|
|
2022-09-28 04:11:27 +02:00
|
|
|
const validator = new Validator();
|
|
|
|
const result = validator.validate({ icons }, schema);
|
|
|
|
if (result.errors.length > 0) {
|
2023-08-08 06:38:52 +02:00
|
|
|
result.errors.forEach((error) => console.error(error));
|
2022-09-28 04:11:27 +02:00
|
|
|
console.error(`Found ${result.errors.length} error(s) in simple-icons.json`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|