findRepoRoot function
Repository root, located by walking up to the workspace pubspec.
Implementation
String findRepoRoot([String? start]) {
var dir = Directory(start ?? Directory.current.path).absolute;
while (true) {
if (File(
p.join(dir.path, 'fixtures', 'java', 'basic', 'api-versions.xml'),
).existsSync()) {
return dir.path;
}
final parent = dir.parent;
if (parent.path == dir.path) {
throw StateError(
'Repository root not found from ${start ?? Directory.current.path}',
);
}
dir = parent;
}
}