forked from openclaw/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.performance-config.ts
More file actions
37 lines (32 loc) · 1.1 KB
/
vitest.performance-config.ts
File metadata and controls
37 lines (32 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
type EnvMap = Record<string, string | undefined>;
const isEnabled = (value: string | undefined): boolean => {
const normalized = value?.trim().toLowerCase();
return normalized === "1" || normalized === "true";
};
const isDisabled = (value: string | undefined): boolean => {
const normalized = value?.trim().toLowerCase();
return normalized === "0" || normalized === "false";
};
export function loadVitestExperimentalConfig(env: EnvMap = process.env): {
experimental?: {
fsModuleCache?: true;
importDurations?: { print: true };
printImportBreakdown?: true;
};
} {
const experimental: {
fsModuleCache?: true;
importDurations?: { print: true };
printImportBreakdown?: true;
} = {};
if (!isDisabled(env.OPENCLAW_VITEST_FS_MODULE_CACHE)) {
experimental.fsModuleCache = true;
}
if (isEnabled(env.OPENCLAW_VITEST_IMPORT_DURATIONS)) {
experimental.importDurations = { print: true };
}
if (isEnabled(env.OPENCLAW_VITEST_PRINT_IMPORT_BREAKDOWN)) {
experimental.printImportBreakdown = true;
}
return Object.keys(experimental).length > 0 ? { experimental } : {};
}