Files
openclaw/test/helpers/vitest-config-paths.ts
2026-04-10 15:49:37 +01:00

21 lines
565 B
TypeScript

import path from "node:path";
export function normalizeConfigPath(value: unknown): unknown {
if (typeof value !== "string" || !path.isAbsolute(value)) {
return value;
}
return path.relative(process.cwd(), value).split(path.sep).join("/");
}
export function normalizeConfigPaths(
values: readonly unknown[] | string | undefined,
): unknown[] | undefined {
if (values === undefined) {
return undefined;
}
if (!Array.isArray(values)) {
return [normalizeConfigPath(values)];
}
return values.map((value) => normalizeConfigPath(value));
}