(tsconfig?: string)
| 38 | } |
| 39 | |
| 40 | export 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 | } |
no test coverage detected