MCPcopy
hub / github.com/kuma-ui/kuma-ui / getUserTheme

Function getUserTheme

packages/webpack-plugin/src/getUserTheme.ts:9–40  ·  view source on GitHub ↗
(configPath: string)

Source from the content-addressed store, hash-verified

7let pervUserTheme: Partial<UserTheme> | undefined;
8
9export const getUserTheme = (configPath: string) => {
10 const configText = fs.readFileSync(configPath, "utf8");
11 const isChanged = configText !== prevConfigText;
12 prevConfigText = configText;
13
14 if (!isChanged) {
15 return pervUserTheme;
16 }
17
18 const result = buildSync({
19 bundle: true,
20 target: "es2017",
21 write: false,
22 platform: "node",
23 format: typeof require !== "undefined" ? "cjs" : "esm",
24 absWorkingDir: process.cwd(),
25 outfile: configPath + ".out",
26 entryPoints: [configPath],
27 logLevel: "silent",
28 });
29
30 const { default: userTheme } = _eval(
31 result.outputFiles[0].text,
32 configPath,
33 ) as {
34 default: Partial<UserTheme>;
35 };
36
37 pervUserTheme = userTheme;
38
39 return userTheme;
40};

Callers 2

applyMethod · 0.90
kumaUiLoaderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected