mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-12-03 16:59:42 +00:00
* Adjust categories * Fix duplicates * Adjust categories * fix(icons/circle-letter-p): restore parking related categories to parking icons * Update icons/heart.json Co-authored-by: Karsa <contact@karsa.org> * fix(icons/zap): add weather to zap & remove category inheritance from zap-off --------- Co-authored-by: Karsa <contact@karsa.org>
27 lines
716 B
TypeScript
27 lines
716 B
TypeScript
import fs from 'fs/promises';
|
|
import path from 'path';
|
|
|
|
/**
|
|
* Reads metadata for an icon or category
|
|
*
|
|
* @param {string} fileName
|
|
* @param {string} directory
|
|
* @returns {object} The metadata for the icon or category
|
|
*/
|
|
export const readMetadata = async (fileName: string, directory: string): Promise<unknown> => {
|
|
let metadataFileContent: string | Buffer = await fs.readFile(
|
|
path.join(directory, fileName),
|
|
'utf-8',
|
|
);
|
|
|
|
if (Buffer.isBuffer(metadataFileContent)) {
|
|
metadataFileContent = metadataFileContent.toString('utf-8');
|
|
}
|
|
|
|
try {
|
|
return JSON.parse(metadataFileContent);
|
|
} catch (error) {
|
|
throw new Error(`Error parsing metadata file ${fileName}: ${String(error)}`);
|
|
}
|
|
};
|