Skip to content

Commit

Permalink
chore(lint): Prettier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 14, 2023
1 parent fdb98c6 commit 4f7459b
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions packages/core/src/vite-plugin-astro-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export async function createPlugin(
const resolvedVirtualModuleId = "\0" + virtualModuleId;

// Load collections
let collections = await loadCollections({ include, iconDir }, { root })
let collections = await loadCollections({ include, iconDir }, { root });

return {
name: "astro-icon",
resolveId(id) {
Expand All @@ -27,27 +27,35 @@ export async function createPlugin(
},
async load(id) {
if (id === resolvedVirtualModuleId) {
collections = await loadCollections({ include, iconDir }, { root })
return `export default ${JSON.stringify(collections)};\nexport const config = ${JSON.stringify({ include })}`;
collections = await loadCollections({ include, iconDir }, { root });
return `export default ${JSON.stringify(
collections
)};\nexport const config = ${JSON.stringify({ include })}`;
}
},
};
}

async function loadCollections({ include, iconDir }: Required<Pick<IntegrationOptions, 'include' | 'iconDir'>>, { root }: Pick<AstroConfig, "root">) {
async function loadCollections(
{
include,
iconDir,
}: Required<Pick<IntegrationOptions, "include" | "iconDir">>,
{ root }: Pick<AstroConfig, "root">
) {
const collections = await loadIconifyCollections(include);

try {
// Attempt to create local collection
const local = await loadLocalCollection(iconDir);
collections["local"] = local;
} catch (ex) {
// Failed to load the local collection
}

await generateIconTypeDefinitions(Object.values(collections), root);
return collections

return collections;
}

async function generateIconTypeDefinitions(
Expand Down Expand Up @@ -87,4 +95,3 @@ async function ensureDir(path: URL): Promise<void> {
await mkdir(path);
}
}

0 comments on commit 4f7459b

Please sign in to comment.