forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtailwind.ts
40 lines (35 loc) · 1.04 KB
/
tailwind.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
const tailwindConfigFiles: string[] = [
'tailwind.config.js',
'tailwind.config.cjs',
'tailwind.config.mjs',
'tailwind.config.ts',
];
export async function findTailwindConfigurationFile(
workspaceRoot: string,
projectRoot: string,
): Promise<string | undefined> {
const dirEntries = [projectRoot, workspaceRoot].map((root) =>
readdir(root, { withFileTypes: false }).then((entries) => ({
root,
files: new Set(entries),
})),
);
// A configuration file can exist in the project or workspace root
for (const { root, files } of await Promise.all(dirEntries)) {
for (const potentialConfig of tailwindConfigFiles) {
if (files.has(potentialConfig)) {
return join(root, potentialConfig);
}
}
}
return undefined;
}