( searchPath: string, )
| 24 | >() |
| 25 | |
| 26 | async function loadFileConfig( |
| 27 | searchPath: string, |
| 28 | ): Promise<PostCSSConfigResult | null> { |
| 29 | const cached = fileConfigCache.get(searchPath) |
| 30 | if (cached !== undefined) return cached |
| 31 | |
| 32 | const promise = (async (): Promise<PostCSSConfigResult | null> => { |
| 33 | try { |
| 34 | const postcssrc = (await import('postcss-load-config')).default |
| 35 | const result = await postcssrc({}, searchPath) |
| 36 | return { |
| 37 | options: result.options, |
| 38 | plugins: result.plugins, |
| 39 | } |
| 40 | } catch (error: any) { |
| 41 | if (error.message?.includes('No PostCSS Config found')) { |
| 42 | return null |
| 43 | } |
| 44 | throw error |
| 45 | } |
| 46 | })() |
| 47 | |
| 48 | fileConfigCache.set(searchPath, promise) |
| 49 | const result = await promise |
| 50 | fileConfigCache.set(searchPath, result) |
| 51 | return result |
| 52 | } |
| 53 | |
| 54 | function resolvePostCSSConfig( |
| 55 | postcssOption: PostCSSOptions | undefined, |
no outgoing calls
no test coverage detected