2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-10 07:11:00 +00:00
This commit is contained in:
Joaquín Sánchez Jiménez 2021-12-12 15:52:01 +01:00
parent c119726e1a
commit 052c86c07b
3 changed files with 12 additions and 12 deletions

View File

@ -8,7 +8,7 @@ export function FileSystemIconLoader(dir: string, transform?: (svg: string) => A
const paths = [
`${dir}/${name}.svg`,
`${dir}/${camelize(name)}.svg`,
`${dir}/${pascalize(name)}.svg`,
`${dir}/${pascalize(name)}.svg`
];
for (const path of paths) {
if (existsSync(path)) {

View File

@ -1,5 +1,5 @@
import type { Awaitable } from '@antfu/utils';
export type CustomIconLoader = (name: string) => Awaitable<string | undefined>
export type InlineCollection = Record<string, string | (() => Awaitable<string | undefined>)>
export type CustomCollections = Record<string, CustomIconLoader | InlineCollection>
export type CustomIconLoader = (name: string) => Awaitable<string | undefined>;
export type InlineCollection = Record<string, string | (() => Awaitable<string | undefined>)>;
export type CustomCollections = Record<string, CustomIconLoader | InlineCollection>;

View File

@ -8,7 +8,7 @@ export function camelize(str: string): string {
export function pascalize(str: string): string {
const camel = camelize(str);
return camel[0].toUpperCase() + camel.slice(1);
return `${camel[0].toUpperCase()}${camel.slice(1)}`;
}
export function camelToKebab(key: string): string {
@ -19,12 +19,12 @@ export function camelToKebab(key: string): string {
return result.split(/\s+/g).join('-').toLowerCase();
}
const warnned = new Set<string>();
const warned = new Set<string>();
export function warnOnce(msg: string): void {
if (!warnned.has(msg)) {
warnned.add(msg);
console.warn(yellow(`[@iconify-loader] ${msg}`))
if (!warned.has(msg)) {
warned.add(msg);
console.warn(yellow(`[@iconify-loader] ${msg}`));
}
}
@ -44,11 +44,11 @@ export async function tryInstallPkg(name: string): Promise<void | undefined> {
.then(() => sleep(300))
// eslint-disable-next-line
.catch((e: any) => {
warnOnce(`Failed to install ${name}`)
console.error(e)
warnOnce(`Failed to install ${name}`);
console.error(e);
})
.finally(() => {
pending = undefined
pending = undefined;
});
}