MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / collectCandidateDirectories

Function collectCandidateDirectories

src/lib/prettierFormatter.js:180–204  ·  view source on GitHub ↗
(fileUri, projectRoot)

Source from the content-addressed store, hash-verified

178}
179
180function collectCandidateDirectories(fileUri, projectRoot) {
181 const directories = [];
182 const visited = new Set();
183 let currentDir = safeDirname(fileUri);
184
185 while (currentDir) {
186 const normalized = normalizePath(currentDir);
187 if (visited.has(normalized)) break;
188 directories.push(currentDir);
189 visited.add(normalized);
190 if (projectRoot && pathsAreSame(currentDir, projectRoot)) break;
191 const parent = safeDirname(currentDir);
192 if (!parent || parent === currentDir) break;
193 currentDir = parent;
194 }
195
196 if (
197 projectRoot &&
198 !directories.some((dir) => pathsAreSame(dir, projectRoot))
199 ) {
200 directories.push(projectRoot);
201 }
202
203 return directories;
204}
205
206function safeDirname(path) {
207 try {

Callers 1

loadProjectConfigFunction · 0.85

Calls 4

safeDirnameFunction · 0.85
normalizePathFunction · 0.85
pathsAreSameFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected