mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:00:42 +00:00
test: reuse runtime sidecar uniqueness helper
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import bundledRuntimeSidecarPaths from "../../scripts/lib/bundled-runtime-sidecar-paths.json" with { type: "json" };
|
||||
|
||||
function assertUniqueValues<T extends string>(values: readonly T[], label: string): readonly T[] {
|
||||
export function assertUniqueValues<T extends string>(
|
||||
values: readonly T[],
|
||||
label: string,
|
||||
): readonly T[] {
|
||||
const seen = new Set<string>();
|
||||
const duplicates = new Set<string>();
|
||||
for (const value of values) {
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../../../src/plugins/runtime-sidecar-paths.js";
|
||||
|
||||
function assertUniqueValues<T extends string>(values: readonly T[], label: string): readonly T[] {
|
||||
const seen = new Set<string>();
|
||||
const duplicates = new Set<string>();
|
||||
for (const value of values) {
|
||||
if (seen.has(value)) {
|
||||
duplicates.add(value);
|
||||
continue;
|
||||
}
|
||||
seen.add(value);
|
||||
}
|
||||
if (duplicates.size > 0) {
|
||||
throw new Error(`Duplicate ${label}: ${Array.from(duplicates).join(", ")}`);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
import {
|
||||
assertUniqueValues,
|
||||
BUNDLED_RUNTIME_SIDECAR_PATHS,
|
||||
} from "../../../src/plugins/runtime-sidecar-paths.js";
|
||||
|
||||
export function getPublicArtifactBasename(relativePath: string): string {
|
||||
return relativePath.split("/").at(-1) ?? relativePath;
|
||||
|
||||
Reference in New Issue
Block a user