fix: resolve symlinked argv1 for Control UI asset detection (#14919)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 07b85041dc
Co-authored-by: gumadeiras <116837+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
Gustavo Madeira Santana
2026-02-12 14:45:31 -05:00
committed by GitHub
parent bdd0c12329
commit 8d5094e1f4
3 changed files with 126 additions and 3 deletions

View File

@@ -60,6 +60,18 @@ function findPackageRootSync(startDir: string, maxDepth = 12): string | null {
function candidateDirsFromArgv1(argv1: string): string[] {
const normalized = path.resolve(argv1);
const candidates = [path.dirname(normalized)];
// Resolve symlinks for version managers (nvm, fnm, n, Homebrew/Linuxbrew)
// that create symlinks in bin/ pointing to the real package location.
try {
const resolved = fsSync.realpathSync(normalized);
if (resolved !== normalized) {
candidates.push(path.dirname(resolved));
}
} catch {
// realpathSync throws if path doesn't exist; keep original candidates
}
const parts = normalized.split(path.sep);
const binIndex = parts.lastIndexOf(".bin");
if (binIndex > 0 && parts[binIndex - 1] === "node_modules") {