2024-03-24 20:38:18 +03:00
|
|
|
#!/usr/bin/env node
|
2021-10-25 22:13:10 +03:00
|
|
|
/**
|
|
|
|
* @fileoverview
|
|
|
|
* CLI tool to run jsonschema on the simple-icons.json data file.
|
|
|
|
*/
|
2021-02-19 17:19:22 +03:00
|
|
|
|
2023-08-08 07:38:52 +03:00
|
|
|
import process from 'node:process';
|
2024-03-24 20:38:18 +03:00
|
|
|
import {Validator} from 'jsonschema';
|
|
|
|
import {getIconsData} from '../../sdk.mjs';
|
|
|
|
import {getJsonSchemaData} from '../utils.js';
|
2021-12-25 17:22:56 +03:00
|
|
|
|
2022-09-28 05:11:27 +03:00
|
|
|
const icons = await getIconsData();
|
2023-08-08 07:38:52 +03:00
|
|
|
const schema = await getJsonSchemaData();
|
2021-10-25 22:13:10 +03:00
|
|
|
|
2022-09-28 05:11:27 +03:00
|
|
|
const validator = new Validator();
|
2024-03-24 20:38:18 +03:00
|
|
|
const result = validator.validate({icons}, schema);
|
2022-09-28 05:11:27 +03:00
|
|
|
if (result.errors.length > 0) {
|
2024-03-24 20:38:18 +03:00
|
|
|
for (const error of result.errors) console.error(error);
|
2022-09-28 05:11:27 +03:00
|
|
|
console.error(`Found ${result.errors.length} error(s) in simple-icons.json`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|