( filename: string, schema: z.ZodType<T>, filetype: string | undefined = undefined )
| 93 | * @returns Validated config object, or null if file doesn't exist |
| 94 | */ |
| 95 | export async function readConfigIfExists<T>( |
| 96 | filename: string, |
| 97 | schema: z.ZodType<T>, |
| 98 | filetype: string | undefined = undefined |
| 99 | ): Promise<T | null> { |
| 100 | const content = await readFileTextIfExists(filename); |
| 101 | if (content == null) { |
| 102 | return null; |
| 103 | } |
| 104 | return parseConfig(content, filename, schema, filetype); |
| 105 | } |
no test coverage detected