MCPcopy Create free account
hub / github.com/craftreactnative/ui / detectRootFolder

Function detectRootFolder

cli/src/utils/project-detection.ts:228–245  ·  view source on GitHub ↗
(targetPath: string)

Source from the content-addressed store, hash-verified

226 * For React Native CLI, it could be 'src' or the root
227 */
228export async function detectRootFolder(targetPath: string): Promise<string> {
229 // Check for common folders in order of preference
230 const possibleRoots = ["app", "src"];
231
232 for (const root of possibleRoots) {
233 const rootPath = path.join(targetPath, root);
234 if (await fs.pathExists(rootPath)) {
235 const stats = await fs.stat(rootPath);
236 if (stats.isDirectory()) {
237 return root;
238 }
239 }
240 }
241
242 // Default fallback to 'app' for Expo projects or '.' for others
243 const isExpoProject = await isExpo(targetPath);
244 return isExpoProject ? "app" : ".";
245}

Callers 1

setupBabelConfigFunction · 0.90

Calls 1

isExpoFunction · 0.85

Tested by

no test coverage detected