root property

String? get root

Implementation

String? get root {
  var directory = fs.currentDirectory.absolute;

  while (true) {
    final file = directory.childFile('pubspec.yaml');

    if (file.existsSync()) {
      return directory.path;
    }

    final parent = directory.parent;
    // Drive roots (e.g. `C:\`) have parent.path == path; stop there.
    // Comparing only to path.separator misses Windows drive roots.
    if (parent.path == directory.path) {
      return null;
    }

    directory = parent;
  }
}