mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-14 15:16:35 +03:00
Fix: match unique --target names after cwd absolutizing
Live and other helpers resolve --target against cwd before context.mjs sees it. Treat a missing single-segment path the same as a bare workspace name so those callers still select the unique child. AI assistance: Cursor Grok 4.6 implemented this change. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -255,10 +255,16 @@ function resolveTargetPath(cwd, targetPath) {
|
||||
}
|
||||
|
||||
function findUniqueBareTarget(cwd, targetPath) {
|
||||
if (path.isAbsolute(targetPath) || /[\\/]/.test(targetPath)) return null;
|
||||
const repoRoot = findMonorepoRoot(path.resolve(cwd));
|
||||
const absCwd = path.resolve(cwd);
|
||||
const abs = path.isAbsolute(targetPath) ? targetPath : path.resolve(absCwd, targetPath);
|
||||
const rel = path.relative(absCwd, abs);
|
||||
if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return null;
|
||||
const segments = rel.split(path.sep).filter(Boolean);
|
||||
if (segments.length !== 1) return null;
|
||||
const name = segments[0];
|
||||
const repoRoot = findMonorepoRoot(absCwd);
|
||||
if (!repoRoot) return null;
|
||||
const matches = discoverTargetCandidates(repoRoot).filter((candidate) => candidate.name === targetPath);
|
||||
const matches = discoverTargetCandidates(repoRoot).filter((candidate) => candidate.name === name);
|
||||
if (matches.length !== 1) return null;
|
||||
return path.resolve(repoRoot, matches[0].path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user