MCPcopy Create free account
hub / github.com/formkit/formkit / localTheme

Function localTheme

packages/cli/src/theme.ts:596–613  ·  view source on GitHub ↗
(
  themeName: string
)

Source from the content-addressed store, hash-verified

594}
595
596async function localTheme(
597 themeName: string
598): Promise<Theme<ThemeOptions>> | never {
599 const extensions = ['.ts', '.js', '.mjs', '.cjs']
600 const paths = HAS_EXTENSION_RE.test(themeName)
601 ? [resolve(process.cwd(), themeName)]
602 : extensions.map((ext) => resolve(process.cwd(), themeName + ext))
603 const path = getPath(paths)
604 if (!path) error(`Could not find ${themeName}.`)
605
606 const jiti = createJiti(import.meta.url, { interopDefault: true })
607 const theme = (await jiti.import(path, {})) as
608 | Theme<ThemeOptions>
609 | { default?: Theme<ThemeOptions> }
610 const themeFunction = typeof theme === 'function' ? theme : theme.default
611 if (!themeFunction) error('Invalid theme file.')
612 return themeFunction
613}
614
615export function extractThemeData(
616 theme: string

Callers 1

buildThemeFunction · 0.85

Calls 2

errorFunction · 0.90
getPathFunction · 0.85

Tested by

no test coverage detected