-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add autoload config with js, json and yml ext
- Loading branch information
Showing
2 changed files
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { Platform } from 'style-dictionary' | ||
import fg from 'fast-glob' | ||
|
||
export type Config = { | ||
entry: Record<string, string> | ||
output: Record<string, Platform> | ||
} | ||
|
||
export async function loadConfig(path: string): Promise<Config> { | ||
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]) | ||
} |