getRootDirectory function

String getRootDirectory()

Implementation

String getRootDirectory() {
  String currentDir = Directory.current.path;
  while (!File(path.join(currentDir, 'pubspec.yaml')).existsSync()) {
    String parentDir = path.dirname(currentDir);
    if (currentDir == parentDir) {
      throw Exception("Unable to find the root directory of the project.");
    }
    currentDir = parentDir;
  }
  return currentDir;
}