( filePath: string, inputDir: string, )
| 11 | let prettierConfigCache = expiringMap<string, string | null>(10_000) |
| 12 | |
| 13 | async function resolvePrettierConfigDir( |
| 14 | filePath: string, |
| 15 | inputDir: string, |
| 16 | ): Promise<string> { |
| 17 | // Check cache for this directory |
| 18 | let cached = prettierConfigCache.get(inputDir) |
| 19 | if (cached !== undefined) { |
| 20 | return cached ?? process.cwd() |
| 21 | } |
| 22 | |
| 23 | const resolve = async () => { |
| 24 | try { |
| 25 | return await prettier.resolveConfigFile(filePath) |
| 26 | } catch (err) { |
| 27 | console.error('prettier-config-not-found', 'Failed to resolve Prettier Config') |
| 28 | console.error('prettier-config-not-found-err', err) |
| 29 | return null |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | let prettierConfig = await resolve() |
| 34 | |
| 35 | // Cache all directories from inputDir up to config location |
| 36 | if (prettierConfig) { |
| 37 | let configDir = path.dirname(prettierConfig) |
| 38 | cacheForDirs(prettierConfigCache, inputDir, configDir, configDir) |
| 39 | return configDir |
| 40 | } else { |
| 41 | prettierConfigCache.set(inputDir, null) |
| 42 | return process.cwd() |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | export async function getTailwindConfig(options: ParserOptions): Promise<UnifiedApi> { |
| 47 | let cwd = process.cwd() |
no test coverage detected
searching dependent graphs…