totopo 3.3.2 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/shadows.js +14 -2
- package/package.json +1 -1
package/dist/lib/shadows.js
CHANGED
|
@@ -28,7 +28,7 @@ export function expandShadowPatterns(patterns, workspaceRoot) {
|
|
|
28
28
|
dot: true,
|
|
29
29
|
ignore: ignorePatterns,
|
|
30
30
|
});
|
|
31
|
-
return results.sort();
|
|
31
|
+
return removeNestedPaths(results.sort());
|
|
32
32
|
}
|
|
33
33
|
// --- Hit counting (for menu UX) ----------------------------------------------------------------------------------------------------------
|
|
34
34
|
/** Count how many paths a pattern would match in the workspace. */
|
|
@@ -97,7 +97,7 @@ function removeStaleEntries(baseDir, currentDir, expected) {
|
|
|
97
97
|
}
|
|
98
98
|
if (entry.isDirectory()) {
|
|
99
99
|
// Check if any expected path is nested under this directory
|
|
100
|
-
const hasExpectedChild = [...expected].some((p) => p
|
|
100
|
+
const hasExpectedChild = [...expected].some((p) => isDescendantOf(p, rel));
|
|
101
101
|
if (hasExpectedChild) {
|
|
102
102
|
// Recurse into the directory to clean stale children
|
|
103
103
|
removeStaleEntries(baseDir, fullPath, expected);
|
|
@@ -117,3 +117,15 @@ function removeStaleEntries(baseDir, currentDir, expected) {
|
|
|
117
117
|
safeRmSync(currentDir, { recursive: true, force: true });
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Drop paths that descend from another path in the input (keeps only the outermost path per subtree),
|
|
122
|
+
* so nested matches (e.g. node_modules inside a shadowed .next dir) don't become redundant bind mounts.
|
|
123
|
+
*/
|
|
124
|
+
function removeNestedPaths(paths) {
|
|
125
|
+
const unique = [...new Set(paths)];
|
|
126
|
+
return unique.filter((p) => !unique.some((a) => a !== p && isDescendantOf(p, a)));
|
|
127
|
+
}
|
|
128
|
+
// Expects forward-slash paths (fast-glob output and shadows/ relative paths on POSIX).
|
|
129
|
+
function isDescendantOf(child, ancestor) {
|
|
130
|
+
return child.startsWith(`${ancestor}/`);
|
|
131
|
+
}
|