Skip to content

Commit

Permalink
move warning about local directory to on use (#123)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Stramel <michael.stramel@koyfin.com>
  • Loading branch information
2 people authored and natemoo-re committed Dec 22, 2023
1 parent f57f028 commit a5c91e3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-beers-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro-icon": patch
---

move warning about local directory to on use
10 changes: 10 additions & 0 deletions packages/core/components/Icon.astro
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ if (!iconName) {
iconName = setName;
setName = "local";
// Check if the local icon set exists
if (!icons[setName]) {
const err = new Error('Unable to load the "local" icon set!');
if (import.meta.env.DEV) {
err.hint =
'It looks like the "local" set was not loaded.\n\nDid you forget to create the icon directory or to update your config?';
}
throw err;
}
// Check if the icon is missing from the local collection
if (!(iconName in icons[setName].icons)) {
const err = new Error(`Unable to locate "${name}" icon!`);
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/vite-plugin-astro-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export async function createPlugin(
const local = await loadLocalCollection(iconDir);
collections["local"] = local;
} catch (ex) {
console.warn(
"Unable to load local collection. Ensure you have your `iconDir` configured properly."
);
// Failed to load the local collection
}
await generateIconTypeDefinitions(Object.values(collections), root);

Expand Down

0 comments on commit a5c91e3

Please sign in to comment.