Skip to content

Commit

Permalink
perf: cache config path
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Jan 29, 2025
1 parent 7adcbe4 commit 5d70480
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tailwind/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import { existsSync } from "node:fs";
import { basename, dirname, resolve } from "node:path";


const CACHE = new Map<string, string>();

export function findFileRecursive(cwd: string, paths: string[]) {
const resolvedPaths = paths.map(p => resolve(cwd, p));

for(let resolvedPath = resolvedPaths.shift(); resolvedPath !== undefined; resolvedPath = resolvedPaths.shift()){
if(CACHE.has(resolvedPath)){
return CACHE.get(resolvedPath);
}

if(existsSync(resolvedPath)){
CACHE.set(resolvedPath, resolvedPath);
return resolvedPath;
}

Expand Down

0 comments on commit 5d70480

Please sign in to comment.