Skip to content

Commit

Permalink
fix(#176): removes warning when no icon packs are found
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Jan 2, 2024
1 parent 38a3a90 commit 1df1e21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-lizards-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro-icon": patch
---

Removes an unecessary warning when only using local icons
9 changes: 6 additions & 3 deletions packages/core/src/vite-plugin-astro-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export function createPlugin(
if (id === resolvedVirtualModuleId) {
if (!collections) {
collections = await loadIconifyCollections({ root, include });
logCollections(collections, ctx);
}
try {
// Attempt to create local collection
Expand All @@ -43,6 +42,7 @@ export function createPlugin(
} catch (ex) {
// Failed to load the local collection
}
logCollections(collections, { ...ctx, iconDir });
await generateIconTypeDefinitions(Object.values(collections), root);

return `export default ${JSON.stringify(
Expand All @@ -55,13 +55,16 @@ export function createPlugin(

function logCollections(
collections: AstroIconCollectionMap,
{ logger }: PluginContext,
{ logger, iconDir }: PluginContext & { iconDir: string },
) {
if (Object.keys(collections).length === 0) {
logger.warn("No icons detected!");
return;
}
const names: string[] = Object.keys(collections);
const names: string[] = Object.keys(collections).filter(v => v !== 'local');
if (collections['local']) {
names.unshift(iconDir);
}
logger.info(`Loaded icons from ${names.join(", ")}`);
}

Expand Down

0 comments on commit 1df1e21

Please sign in to comment.