perf(theme): improve typo
This commit is contained in:
parent
829fab5508
commit
8d3930560a
@ -3,7 +3,6 @@ export * from './createFsCache.js'
|
||||
export * from './hash.js'
|
||||
export * from './interopDefault.js'
|
||||
export * from './logger.js'
|
||||
export * from './omit.js'
|
||||
export * from './package.js'
|
||||
export * from './path.js'
|
||||
export * from './resolveContent.js'
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export type Awaitable<T> = T | Promise<T>
|
||||
import type { Awaitable } from '@pengzhanbo/utils'
|
||||
|
||||
export async function interopDefault<T>(m: Awaitable<T>): Promise<T extends { default: infer U } ? U : T> {
|
||||
const resolved = await m
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
export function omit<
|
||||
T extends Record<string, any> = Record<string, any>,
|
||||
>(obj: T, ...attrs: (keyof T)[]): Omit<T, keyof T> {
|
||||
const res = {} as T
|
||||
|
||||
for (const key in obj) {
|
||||
if (!attrs.includes(key)) {
|
||||
res[key] = obj[key]
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
@ -2,22 +2,19 @@ import process from 'node:process'
|
||||
import { fs, path } from 'vuepress/utils'
|
||||
import { resolve } from './path.js'
|
||||
|
||||
export function getPackage() {
|
||||
let pkg = {} as any
|
||||
export function readJsonFileAsync<T extends Record<string, any> = Record<string, any>>(filePath: string): T {
|
||||
try {
|
||||
const content = fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8')
|
||||
pkg = JSON.parse(content)
|
||||
const content = fs.readFileSync(filePath, 'utf-8')
|
||||
return JSON.parse(content)
|
||||
}
|
||||
catch { }
|
||||
return pkg
|
||||
catch {}
|
||||
return {} as T
|
||||
}
|
||||
|
||||
export function getPackage() {
|
||||
return readJsonFileAsync(path.join(process.cwd(), 'package.json'))
|
||||
}
|
||||
|
||||
export function getThemePackage() {
|
||||
let pkg = {} as any
|
||||
try {
|
||||
const content = fs.readFileSync(resolve('.../../package.json'), 'utf-8')
|
||||
pkg = JSON.parse(content)
|
||||
}
|
||||
catch {}
|
||||
return pkg
|
||||
return readJsonFileAsync(resolve('.../../package.json'))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user