mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 06:07:40 +01:00
fix: properly select icons dir for tags & error if no metadata found (#3411)
Fixes #3359 Throwing an error in readAllMetadata now to ensure this error can't happen again in the future. The error was caused by this script being moved to a different dir, but the relative url not being updated, causing no icons to be found.
This commit is contained in:
@@ -2,7 +2,9 @@ import path from 'path';
|
||||
import { writeFile, getCurrentDirPath, readAllMetadata } from '@lucide/helpers';
|
||||
|
||||
const currentDir = getCurrentDirPath(import.meta.url);
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
|
||||
const PACKAGE_DIR = path.resolve(currentDir, '../');
|
||||
const ICONS_DIR = path.join(PACKAGE_DIR, '../../icons');
|
||||
const icons = await readAllMetadata(ICONS_DIR);
|
||||
|
||||
const tags = Object.keys(icons)
|
||||
|
||||
@@ -16,6 +16,9 @@ export const readAllMetadata = async (directory: string): Promise<Record<string,
|
||||
.map(async (file) => [path.basename(file, '.json'), await readMetadata(file, directory)]);
|
||||
|
||||
const metadata = await Promise.all(metaDataPromises);
|
||||
if (metadata.length === 0) {
|
||||
throw new Error(`No metadata files found in directory: ${directory}`);
|
||||
}
|
||||
|
||||
return Object.fromEntries(metadata);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user