findNitroProjectRoot function
Searches for a Nitro project root. Checks the current directory first, then direct subdirectories. Returns the Directory if a pubspec.yaml containing 'nitro' is found.
Implementation
Directory? findNitroProjectRoot({String? startDir}) {
final root = startDir != null ? Directory(startDir) : Directory.current;
// 1. Check root directory
if (_isNitroRoot(root)) return root;
// 2. Check direct subdirectories (common in monorepos or after init)
try {
for (final entity in root.listSync()) {
if (entity is Directory && _isNitroRoot(entity)) {
return entity;
}
}
} catch (_) {}
return null;
}