1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2025-11-23 21:34:49 +02:00

Refactor tests and scripts (#9237)

Co-authored-by: LitoMore <LitoMore@users.noreply.github.com>
This commit is contained in:
Álvaro Mondéjar
2023-08-07 22:38:52 -06:00
committed by GitHub
parent 8abcd9c8b9
commit 17ea889273
17 changed files with 138 additions and 129 deletions

View File

@@ -3,22 +3,18 @@
* CLI tool to run jsonschema on the simple-icons.json data file.
*/
import path from 'node:path';
import process from 'node:process';
import { Validator } from 'jsonschema';
import { getDirnameFromImportMeta, getIconsData } from '../../sdk.mjs';
import { getIconsData } from '../../sdk.mjs';
import { getJsonSchemaData } from '../utils.js';
const icons = await getIconsData();
const __dirname = getDirnameFromImportMeta(import.meta.url);
const schema = await getJsonSchemaData(path.resolve(__dirname, '..', '..'));
const schema = await getJsonSchemaData();
const validator = new Validator();
const result = validator.validate({ icons }, schema);
if (result.errors.length > 0) {
result.errors.forEach((error) => {
console.error(error);
});
result.errors.forEach((error) => console.error(error));
console.error(`Found ${result.errors.length} error(s) in simple-icons.json`);
process.exit(1);
}