mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 12:10:30 +00:00
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import path from "node:path";
|
|
import {
|
|
bundledPluginDependentUnitTestFiles,
|
|
unitTestAdditionalExcludePatterns,
|
|
} from "./vitest.unit-paths.mjs";
|
|
import { createUnitVitestConfigWithOptions } from "./vitest.unit.config.ts";
|
|
|
|
function normalizeGlobCandidate(value: string): string {
|
|
return value.split(path.sep).join("/");
|
|
}
|
|
|
|
function excludePatternCouldMatchFile(pattern: string, file: string): boolean {
|
|
const normalizedPattern = normalizeGlobCandidate(pattern);
|
|
const normalizedFile = normalizeGlobCandidate(file);
|
|
if (normalizedPattern === normalizedFile) {
|
|
return true;
|
|
}
|
|
if (normalizedPattern.endsWith("/**")) {
|
|
const prefix = normalizedPattern.slice(0, -3);
|
|
return normalizedFile === prefix || normalizedFile.startsWith(`${prefix}/`);
|
|
}
|
|
return path.matchesGlob(normalizedFile, normalizedPattern);
|
|
}
|
|
|
|
const bundledUnitExcludePatterns = unitTestAdditionalExcludePatterns.filter(
|
|
(pattern) =>
|
|
!bundledPluginDependentUnitTestFiles.some((file) =>
|
|
excludePatternCouldMatchFile(pattern, file),
|
|
),
|
|
);
|
|
|
|
export default createUnitVitestConfigWithOptions(process.env, {
|
|
includePatterns: bundledPluginDependentUnitTestFiles,
|
|
extraExcludePatterns: bundledUnitExcludePatterns,
|
|
name: "bundled",
|
|
});
|