Skip to content

Commit 28c9f9a

Browse files
authored
refactor(infra): reuse canonical PATH prepend normalization (#129028)
1 parent 7c71d41 commit 28c9f9a

1 file changed

Lines changed: 2 additions & 17 deletions

File tree

‎src/infra/path-prepend.ts‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from "node:path";
33
import {
44
normalizeStringEntries,
55
normalizeUniqueStringEntries,
6+
normalizeUniqueTrimmedStringList,
67
} from "@openclaw/normalization-core/string-normalization";
78

89
/**
@@ -24,23 +25,7 @@ export function findPathKey(env: Record<string, string>): string {
2425

2526
/** Normalizes configured PATH prepends by trimming blanks and preserving first-seen order. */
2627
export function normalizePathPrepend(entries?: string[]) {
27-
if (!Array.isArray(entries)) {
28-
return [];
29-
}
30-
const seen = new Set<string>();
31-
const normalized: string[] = [];
32-
for (const entry of entries) {
33-
if (typeof entry !== "string") {
34-
continue;
35-
}
36-
const trimmed = entry.trim();
37-
if (!trimmed || seen.has(trimmed)) {
38-
continue;
39-
}
40-
seen.add(trimmed);
41-
normalized.push(trimmed);
42-
}
43-
return normalized;
28+
return normalizeUniqueTrimmedStringList(entries);
4429
}
4530

4631
/** Merges prepended PATH entries ahead of the existing PATH while deduping normalized parts. */

0 commit comments

Comments
 (0)