resolvePackageBase method

Directory? resolvePackageBase(
  1. Uri uri
)

Implementation

Directory? resolvePackageBase(Uri uri) {
  if (Dart.isWeb) {
    return null;
  }
  Uri? result = resolvePackageUriSync(uri);
  if (result == null) {
    return null;
  }
  for (var i = 0; i < path.split(result.toFilePath()).length; i++) {
    File file_pubspec = File(path.join(
        Directory(path.join(result.toFilePath(),
                List.generate(i, (index) => "..").join(Dart.pathSeparator)))
            .uri
            .toFilePath(),
        "pubspec.yaml"));
    if (file_pubspec.existsSync()) {
      return file_pubspec.parent;
    }
  }

  return null;
}