(configPath: string)
| 7 | let pervUserTheme: Partial<UserTheme> | undefined; |
| 8 | |
| 9 | export 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 | }; |
no outgoing calls
no test coverage detected