MCPcopy
hub / github.com/freshframework/fresh / findTailwindConfigFile

Function findTailwindConfigFile

packages/plugin-tailwindcss-v3/src/mod.ts:76–103  ·  view source on GitHub ↗
(directory: string)

Source from the content-addressed store, hash-verified

74const CONFIG_EXTENSIONS = ["ts", "js", "mjs"];
75
76async function findTailwindConfigFile(directory: string): Promise<string> {
77 let dir = directory;
78 while (true) {
79 for (let i = 0; i < CONFIG_EXTENSIONS.length; i++) {
80 const ext = CONFIG_EXTENSIONS[i];
81 const filePath = path.join(dir, `tailwind.config.${ext}`);
82 try {
83 const stat = await Deno.stat(filePath);
84 if (stat.isFile) {
85 return filePath;
86 }
87 } catch (err) {
88 if (!(err instanceof Deno.errors.NotFound)) {
89 throw err;
90 }
91 }
92 }
93
94 const parent = path.dirname(dir);
95 if (parent === dir) {
96 throw new Error(
97 `Could not find a tailwind config file in the current directory or any parent directory.`,
98 );
99 }
100
101 dir = parent;
102 }
103}
104
105async function initTailwind(
106 config: ResolvedBuildConfig,

Callers 1

initTailwindFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected