forked from dream-num/univer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.workspace.ts
More file actions
46 lines (37 loc) · 1.38 KB
/
vitest.workspace.ts
File metadata and controls
46 lines (37 loc) · 1.38 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
41
42
43
44
45
46
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import fs from 'fs-extra';
import { defineWorkspace } from 'vitest/config';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
function findVitestConfigs(): string[] {
const baseDirs = [
path.resolve(__dirname, './packages'),
path.resolve(__dirname, './packages-experimental'),
path.resolve(__dirname, './tests'),
];
const vitestConfigPaths: string[] = [];
function traverseDir(dir: string) {
const entries = fs.readdirSync(dir, { withFileTypes: true });
for (const entry of entries) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
const packageJsonPath = path.join(fullPath, 'package.json');
if (fs.existsSync(packageJsonPath)) {
const viteConfigPath = path.join(fullPath, 'vitest.config.ts');
if (fs.existsSync(viteConfigPath)) {
vitestConfigPaths.push(viteConfigPath);
}
} else {
traverseDir(fullPath);
}
}
}
}
for (const baseDir of baseDirs) {
if (fs.existsSync(baseDir)) {
traverseDir(baseDir);
}
}
return vitestConfigPaths;
}
export default defineWorkspace(findVitestConfigs());