carto-md 1.0.12 → 1.0.13
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/package.json +1 -1
- package/src/cli/impact.js +9 -8
package/package.json
CHANGED
package/src/cli/impact.js
CHANGED
|
@@ -137,7 +137,6 @@ function run(projectRoot, fileArg) {
|
|
|
137
137
|
* Matches by basename or partial path suffix.
|
|
138
138
|
*/
|
|
139
139
|
function resolveFile(fileArg, imports) {
|
|
140
|
-
// Collect all known files (keys + all values)
|
|
141
140
|
const allFiles = new Set();
|
|
142
141
|
for (const [file, deps] of Object.entries(imports)) {
|
|
143
142
|
allFiles.add(file);
|
|
@@ -145,6 +144,7 @@ function resolveFile(fileArg, imports) {
|
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
const normalized = fileArg.replace(/\\/g, '/');
|
|
147
|
+
const hasPathSeparator = normalized.includes('/');
|
|
148
148
|
|
|
149
149
|
// Exact match
|
|
150
150
|
if (allFiles.has(normalized)) return normalized;
|
|
@@ -153,16 +153,17 @@ function resolveFile(fileArg, imports) {
|
|
|
153
153
|
const matches = [...allFiles].filter(f => f.endsWith('/' + normalized) || f === normalized);
|
|
154
154
|
if (matches.length === 1) return matches[0];
|
|
155
155
|
|
|
156
|
-
//
|
|
156
|
+
// If input was a path (contains /), don't fall back to basename — it's ambiguous
|
|
157
|
+
if (hasPathSeparator) {
|
|
158
|
+
if (matches.length > 1) return null;
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Input is just a filename — fall back to basename matching
|
|
157
163
|
const byBasename = [...allFiles].filter(f => path.basename(f) === path.basename(normalized));
|
|
158
164
|
if (byBasename.length === 1) return byBasename[0];
|
|
159
165
|
|
|
160
|
-
//
|
|
161
|
-
if (byBasename.length > 1) {
|
|
162
|
-
byBasename.sort((a, b) => a.length - b.length);
|
|
163
|
-
return byBasename[0];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
+
// Multiple basename matches — ambiguous, don't guess
|
|
166
167
|
return null;
|
|
167
168
|
}
|
|
168
169
|
|