2024-03-24 19:38:18 +02:00
|
|
|
#!/usr/bin/env node
|
2021-10-25 21:13:10 +02:00
|
|
|
/**
|
2024-06-06 14:40:35 +02:00
|
|
|
* @file
|
2021-10-25 21:13:10 +02:00
|
|
|
* 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';
|
2024-03-24 19:38:18 +02:00
|
|
|
import {Validator} from 'jsonschema';
|
|
|
|
import {getIconsData} from '../../sdk.mjs';
|
|
|
|
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();
|
2024-03-24 19:38:18 +02:00
|
|
|
const result = validator.validate({icons}, schema);
|
2022-09-28 04:11:27 +02:00
|
|
|
if (result.errors.length > 0) {
|
2024-03-24 19:38:18 +02:00
|
|
|
for (const error of result.errors) 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);
|
|
|
|
}
|