mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
26 lines
814 B
TypeScript
26 lines
814 B
TypeScript
// Vitest config path helpers resolve test config fixture paths.
|
|
import path from "node:path";
|
|
|
|
// Path normalization helpers for Vitest config snapshot assertions.
|
|
|
|
/** Convert absolute paths to cwd-relative POSIX-style paths. */
|
|
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("/");
|
|
}
|
|
|
|
/** Normalize one or many config path values. */
|
|
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));
|
|
}
|