18 lines
670 B
TypeScript
18 lines
670 B
TypeScript
import { existsSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const directory = path.dirname(fileURLToPath(import.meta.url))
|
|
const bundledTheme = path.resolve(directory, '..', 'theme')
|
|
const workspaceTheme = path.resolve(directory, '..', '..', 'packages', 'slidev-theme-easy-jyy')
|
|
|
|
export function resolveTheme(theme?: string) {
|
|
if (theme)
|
|
return theme
|
|
if (existsSync(path.join(bundledTheme, 'package.json')))
|
|
return bundledTheme
|
|
if (existsSync(path.join(workspaceTheme, 'package.json')))
|
|
return workspaceTheme
|
|
throw new Error('easy-slides 主题不存在;请重新安装或构建 @easy-slides/cli')
|
|
}
|