diff --git a/src/cli/build.ts b/src/cli/build.ts index 1240250..346eccf 100644 --- a/src/cli/build.ts +++ b/src/cli/build.ts @@ -16,7 +16,7 @@ export default class Build extends Command { config: flags.string({ char: 'c', description: 'The path to a themekit config file.', - default: 'themekit.config.json', + default: 'themekit.config.{js,json,yml}', }), watch: flags.boolean({ char: 'w', diff --git a/src/core/config.ts b/src/core/config.ts index 0454444..7cce524 100644 --- a/src/core/config.ts +++ b/src/core/config.ts @@ -1,4 +1,5 @@ import { Platform } from 'style-dictionary' +import fg from 'fast-glob' export type Config = { entry: Record @@ -6,5 +7,9 @@ export type Config = { } export async function loadConfig(path: string): Promise { - return require(path) + const resolvedPath = fg.sync(path) + if (resolvedPath.length === 0) { + throw new Error(`Cannot load config from "${path}", please check path or file are exists.`) + } + return require(resolvedPath[0]) }