MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / getPackageRoot

Function getPackageRoot

src/core/resource-root.ts:29–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27}
28
29export function getPackageRoot(): string {
30 if (cachedPackageRoot) {
31 return cachedPackageRoot;
32 }
33
34 const candidates: string[] = [];
35 const importMetaUrl = typeof import.meta.url === 'string' ? import.meta.url : null;
36 if (importMetaUrl) {
37 candidates.push(path.dirname(fileURLToPath(importMetaUrl)));
38 }
39 candidates.push(process.cwd());
40 const entry = process.argv[1];
41 if (entry) {
42 candidates.push(path.dirname(entry));
43 }
44
45 for (const candidate of candidates) {
46 const found = findPackageRootFrom(candidate);
47 if (found) {
48 cachedPackageRoot = found;
49 return found;
50 }
51 }
52
53 throw new Error('Could not find package root (no package.json found in parent directories)');
54}
55
56function getExecutableResourceRoot(): string | null {
57 const execPath = process.execPath;

Callers 4

createMcpTestHarnessFunction · 0.90
importResourceModuleFunction · 0.90
importToolModuleFunction · 0.90
getResourceRootFunction · 0.85

Calls 2

findPackageRootFromFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected