mirror of
https://github.com/Mibew/simple-icons.git
synced 2024-11-16 02:14:12 +03:00
17ea889273
Co-authored-by: LitoMore <LitoMore@users.noreply.github.com>
34 lines
969 B
JavaScript
34 lines
969 B
JavaScript
import path from 'node:path';
|
|
import fs from 'node:fs/promises';
|
|
import { getDirnameFromImportMeta, getIconDataPath } from '../sdk.mjs';
|
|
|
|
const __dirname = getDirnameFromImportMeta(import.meta.url);
|
|
|
|
/**
|
|
* Get JSON schema data.
|
|
* @param {String} rootDir Path to the root directory of the project.
|
|
*/
|
|
export const getJsonSchemaData = async (
|
|
rootDir = path.resolve(__dirname, '..'),
|
|
) => {
|
|
const jsonSchemaPath = path.resolve(rootDir, '.jsonschema.json');
|
|
const jsonSchemaString = await fs.readFile(jsonSchemaPath, 'utf8');
|
|
return JSON.parse(jsonSchemaString);
|
|
};
|
|
|
|
/**
|
|
* Write icons data to _data/simple-icons.json.
|
|
* @param {Object} iconsData Icons data object.
|
|
* @param {String} rootDir Path to the root directory of the project.
|
|
*/
|
|
export const writeIconsData = async (
|
|
iconsData,
|
|
rootDir = path.resolve(__dirname, '..'),
|
|
) => {
|
|
await fs.writeFile(
|
|
getIconDataPath(rootDir),
|
|
`${JSON.stringify(iconsData, null, 4)}\n`,
|
|
'utf8',
|
|
);
|
|
};
|