Skip to content

Commit

Permalink
fix: 加载器文件集的键应是文件名而不是路径
Browse files Browse the repository at this point in the history
  • Loading branch information
waset committed Oct 24, 2024
1 parent dfbf9c8 commit dc9eda7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/loader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CustomIconLoader } from './core/types'
import { existsSync, readdirSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
import { basename, join } from 'node:path'
import { cwd } from 'node:process'
import { OUTPUT } from './env'

Expand All @@ -13,7 +13,7 @@ export function UnocssLoader(dir: string = OUTPUT): Record<string, CustomIconLoa
const jsons = getOutputFiles(dir)
const icons: Record<string, CustomIconLoader> = {}
jsons.forEach((file) => {
const name = file.replace('.json', '')
const name = basename(file).replace('.json', '')
icons[name] = () => JSON.parse(readFileSync(file, 'utf-8'))
})

Expand All @@ -33,5 +33,5 @@ export function getOutputFiles(dir: string = OUTPUT): string[] {

const files = readdirSync(srcDir).filter(file => file.endsWith('.json'))

return files.map(file => join(srcDir, file))
return files.map(file => join(dir, file))
}

0 comments on commit dc9eda7

Please sign in to comment.