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

Function autoloadRc

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

Source from the content-addressed store, hash-verified

38}
39
40export async function autoloadRc(tsconfig?: string): Promise<CoreConfig> {
41 const configFilePatterns = [
42 CONFIG_FILE_NAME,
43 `{${SUPPORTED_CONFIG_FILE_FORMATS.join(',')}}`,
44 ].join('.');
45
46 logger.debug(`Looking for default config file ${configFilePatterns}`);
47
48 // eslint-disable-next-line functional/no-let
49 let ext = '';
50 // eslint-disable-next-line functional/no-loop-statements
51 for (const extension of SUPPORTED_CONFIG_FILE_FORMATS) {
52 const filePath = `${CONFIG_FILE_NAME}.${extension}`;
53 const exists = await fileExists(filePath);
54
55 if (exists) {
56 logger.debug(`Found default config file ${ansis.bold(filePath)}`);
57 ext = extension;
58 break;
59 }
60 }
61
62 if (!ext) {
63 throw new Error(
64 `No ${configFilePatterns} file present in ${process.cwd()}`,
65 );
66 }
67
68 return readRcByPath(
69 path.join(process.cwd(), `${CONFIG_FILE_NAME}.${ext}`),
70 tsconfig,
71 );
72}

Callers 2

coreConfigMiddlewareFunction · 0.90

Calls 3

fileExistsFunction · 0.90
readRcByPathFunction · 0.85
debugMethod · 0.45

Tested by

no test coverage detected