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:
Alex
2025-07-30 11:59:46 +02:00
committed by GitHub
parent 31a9cdcbcc
commit 64ddff76c5
2 changed files with 6 additions and 1 deletions

View File

@@ -2,7 +2,9 @@ import path from 'path';
import { writeFile, getCurrentDirPath, readAllMetadata } from '@lucide/helpers'; import { writeFile, getCurrentDirPath, readAllMetadata } from '@lucide/helpers';
const currentDir = getCurrentDirPath(import.meta.url); 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 icons = await readAllMetadata(ICONS_DIR);
const tags = Object.keys(icons) const tags = Object.keys(icons)

View File

@@ -16,6 +16,9 @@ export const readAllMetadata = async (directory: string): Promise<Record<string,
.map(async (file) => [path.basename(file, '.json'), await readMetadata(file, directory)]); .map(async (file) => [path.basename(file, '.json'), await readMetadata(file, directory)]);
const metadata = await Promise.all(metaDataPromises); const metadata = await Promise.all(metaDataPromises);
if (metadata.length === 0) {
throw new Error(`No metadata files found in directory: ${directory}`);
}
return Object.fromEntries(metadata); return Object.fromEntries(metadata);
}; };