2024-03-25 01:38:18 +08: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 15:19:22 +01:00
|
|
|
|
2023-08-07 22:38:52 -06:00
|
|
|
import process from 'node:process';
|
2024-03-25 01:38:18 +08:00
|
|
|
import {Validator} from 'jsonschema';
|
|
|
|
import {getIconsData} from '../../sdk.mjs';
|
|
|
|
import {getJsonSchemaData} from '../utils.js';
|
2021-12-25 06:22:56 -08:00
|
|
|
|
2022-09-28 10:11:27 +08:00
|
|
|
const icons = await getIconsData();
|
2023-08-07 22:38:52 -06:00
|
|
|
const schema = await getJsonSchemaData();
|
2021-10-25 21:13:10 +02:00
|
|
|
|
2022-09-28 10:11:27 +08:00
|
|
|
const validator = new Validator();
|
2024-03-25 01:38:18 +08:00
|
|
|
const result = validator.validate({icons}, schema);
|
2022-09-28 10:11:27 +08:00
|
|
|
if (result.errors.length > 0) {
|
2024-03-25 01:38:18 +08:00
|
|
|
for (const error of result.errors) console.error(error);
|
2022-09-28 10:11:27 +08:00
|
|
|
console.error(`Found ${result.errors.length} error(s) in simple-icons.json`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|