( filePath: string, tsconfig?: string, )
| 10 | import { fileExists, importModule, logger } from '@code-pushup/utils'; |
| 11 | |
| 12 | export async function readRcByPath( |
| 13 | filePath: string, |
| 14 | tsconfig?: string, |
| 15 | ): Promise<CoreConfig> { |
| 16 | const formattedTarget = [ |
| 17 | `${ansis.bold(path.relative(process.cwd(), filePath))}`, |
| 18 | tsconfig && |
| 19 | `(paths from ${ansis.bold(path.relative(process.cwd(), tsconfig))})`, |
| 20 | ] |
| 21 | .filter(Boolean) |
| 22 | .join(' '); |
| 23 | |
| 24 | const value = await logger.task( |
| 25 | `Importing config from ${formattedTarget}`, |
| 26 | async () => { |
| 27 | const result = await importModule({ |
| 28 | filepath: filePath, |
| 29 | tsconfig, |
| 30 | }); |
| 31 | return { result, message: `Imported config from ${formattedTarget}` }; |
| 32 | }, |
| 33 | ); |
| 34 | |
| 35 | const config = validate(coreConfigSchema, value, { filePath }); |
| 36 | logger.info('Configuration is valid ✓'); |
| 37 | return config; |
| 38 | } |
| 39 | |
| 40 | export async function autoloadRc(tsconfig?: string): Promise<CoreConfig> { |
| 41 | const configFilePatterns = [ |
no test coverage detected