Skip to content

Commit c8bca3b

Browse files
committed
fix(cli): detect case-variant collisions in Phase 1 of file resolution
Phase 1 returned the first exact match without checking for case-variant duplicates (e.g. .spm.json and .SPM.json coexisting on a case-sensitive filesystem). Now checks for collisions before returning, matching the existing Phase 2 behaviour.
1 parent a9e4ff7 commit c8bca3b

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/cli/shared.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ export function resolveInput(input?: string, cwd?: string): string {
7272
name.endsWith(".sysprom");
7373
const found = entries.filter((e) => e === name);
7474
if (found.length === 1) {
75+
// Before returning, check for case-variant collisions on case-sensitive
76+
// filesystems (e.g. both .spm.json and .SPM.json exist).
77+
const nameLower = name.toLowerCase();
78+
const caseVariants = entries.filter(
79+
(e) => e !== name && e.toLowerCase() === nameLower,
80+
);
81+
if (caseVariants.length > 0) {
82+
throw new Error(
83+
`Multiple SysProM documents found: ${[name, ...caseVariants].join(", ")}. Specify one explicitly.`,
84+
);
85+
}
7586
const candidate = join(dir, found[0]);
7687
if (isDirSuffix) {
7788
try {

0 commit comments

Comments
 (0)