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

Function findProjectRoot

src/lib/prettierFormatter.js:156–178  ·  view source on GitHub ↗
(uri)

Source from the content-addressed store, hash-verified

154}
155
156function findProjectRoot(uri) {
157 const folders = Array.isArray(globalThis.addedFolder)
158 ? globalThis.addedFolder
159 : [];
160 const target = normalizePath(uri);
161 let match = null;
162 let matchLength = -1;
163
164 for (const folder of folders) {
165 const folderUrl = folder?.url;
166 if (!folderUrl) continue;
167 const normalized = normalizePath(folderUrl);
168 if (!normalized) continue;
169 if (target === normalized || target.startsWith(`${normalized}/`)) {
170 if (normalized.length > matchLength) {
171 match = folderUrl;
172 matchLength = normalized.length;
173 }
174 }
175 }
176
177 return match;
178}
179
180function collectCandidateDirectories(fileUri, projectRoot) {
181 const directories = [];

Callers 1

loadProjectConfigFunction · 0.85

Calls 1

normalizePathFunction · 0.85

Tested by

no test coverage detected