-
-
Notifications
You must be signed in to change notification settings - Fork 393
Expand file tree
/
Copy pathjest.config.ts
More file actions
40 lines (37 loc) · 1.1 KB
/
jest.config.ts
File metadata and controls
40 lines (37 loc) · 1.1 KB
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
import { readdirSync, statSync } from 'fs';
import { join } from 'path';
function findJestConfigs(dir: string, base = ''): string[] {
const results: string[] = [];
try {
const entries = readdirSync(dir, { withFileTypes: true });
for (const entry of entries) {
const fullPath = join(dir, entry.name);
const relPath = base ? `${base}/${entry.name}` : entry.name;
if (entry.isDirectory()) {
if (
entry.name !== 'node_modules' &&
entry.name !== 'dist' &&
entry.name !== '.git' &&
!entry.name.startsWith('.')
) {
results.push(...findJestConfigs(fullPath, relPath));
}
} else if (
entry.isFile() &&
/^jest\.config\.(ts|js|mjs|cjs)$/.test(entry.name)
) {
results.push(join(dir, entry.name));
}
}
} catch {
// ignore
}
return results;
}
const projects = findJestConfigs(join(__dirname, 'packages'))
.concat(findJestConfigs(join(__dirname, 'apps')))
.concat(findJestConfigs(join(__dirname, 'tools')))
.filter((p) => p !== __filename);
export default {
projects,
};