2021-10-25 22:13:10 +03:00
|
|
|
#!/usr/bin/env node
|
|
|
|
/**
|
|
|
|
* @fileoverview
|
|
|
|
* CLI tool to run jsonschema on the simple-icons.json data file.
|
|
|
|
*/
|
2021-02-19 17:19:22 +03:00
|
|
|
|
2021-10-25 22:13:10 +03:00
|
|
|
const path = require('path');
|
|
|
|
const { Validator } = require('jsonschema');
|
|
|
|
|
|
|
|
const rootDir = path.resolve(__dirname, '..', '..');
|
|
|
|
const schemaFile = path.resolve(rootDir, '.jsonschema.json');
|
|
|
|
const dataFile = path.resolve(rootDir, '_data', 'simple-icons.json');
|
2021-02-19 17:19:22 +03:00
|
|
|
|
|
|
|
const schema = require(schemaFile);
|
|
|
|
const data = require(dataFile);
|
|
|
|
|
|
|
|
const validator = new Validator();
|
|
|
|
const result = validator.validate(data, schema);
|
|
|
|
if (result.errors.length > 0) {
|
|
|
|
result.errors.forEach((error) => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
|
|
|
|
console.error(`Found ${result.errors.length} error(s) in simple-icons.json`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|