From 64ddff76c5fe86f6173379fa539915ef3b0dbde4 Mon Sep 17 00:00:00 2001 From: Alex <40795980+AlexProgrammerDE@users.noreply.github.com> Date: Wed, 30 Jul 2025 11:59:46 +0200 Subject: [PATCH] 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. --- packages/lucide-static/scripts/migrateIconsToTags.mts | 4 +++- tools/build-helpers/src/readAllMetadata.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/lucide-static/scripts/migrateIconsToTags.mts b/packages/lucide-static/scripts/migrateIconsToTags.mts index 979c065ba..64228b1cf 100644 --- a/packages/lucide-static/scripts/migrateIconsToTags.mts +++ b/packages/lucide-static/scripts/migrateIconsToTags.mts @@ -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) diff --git a/tools/build-helpers/src/readAllMetadata.ts b/tools/build-helpers/src/readAllMetadata.ts index eda0985af..b66f588d4 100644 --- a/tools/build-helpers/src/readAllMetadata.ts +++ b/tools/build-helpers/src/readAllMetadata.ts @@ -16,6 +16,9 @@ export const readAllMetadata = async (directory: string): Promise [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); };