mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-13 13:48:26 +00:00
22 lines
736 B
TypeScript
22 lines
736 B
TypeScript
import path from 'path';
|
|
import { pathToFileURL } from 'url';
|
|
import { readSvgDirectory } from '@lucide/helpers';
|
|
import { type IconMetadata } from '../types.ts';
|
|
|
|
async function getIconMetaData(iconDirectory: string): Promise<Record<string, IconMetadata>> {
|
|
const iconJsons = await readSvgDirectory(iconDirectory, '.json');
|
|
const aliasesEntries = await Promise.all(
|
|
iconJsons.map(async (jsonFile: string) => {
|
|
/** eslint-disable */
|
|
const file = await import(pathToFileURL(path.join(iconDirectory, jsonFile)).href, {
|
|
with: { type: 'json' },
|
|
});
|
|
return [path.basename(jsonFile, '.json'), file.default];
|
|
}),
|
|
);
|
|
|
|
return Object.fromEntries(aliasesEntries);
|
|
}
|
|
|
|
export default getIconMetaData;
|