MCPcopy Create free account
hub / github.com/code-pushup/cli / readRcByPath

Function readRcByPath

packages/core/src/lib/implementation/read-rc-file.ts:12–38  ·  view source on GitHub ↗
(
  filePath: string,
  tsconfig?: string,
)

Source from the content-addressed store, hash-verified

10import { fileExists, importModule, logger } from '@code-pushup/utils';
11
12export 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
40export async function autoloadRc(tsconfig?: string): Promise<CoreConfig> {
41 const configFilePatterns = [

Callers 3

coreConfigMiddlewareFunction · 0.90
autoloadRcFunction · 0.85

Calls 4

importModuleFunction · 0.90
validateFunction · 0.90
taskMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected