parsePubspecOverrides function

Future<Map<String, Dependency>> parsePubspecOverrides(
  1. Directory directory
)

Parse the pubspec_overrides.yaml of the given directory.

Throws if the parsing fails, such as if the file is badly formatted or does not exists.

Implementation

Future<Map<String, Dependency>> parsePubspecOverrides(
  Directory directory,
) async {
  final content = await directory.pubspecOverrides.readAsString();
  // Pubspec.parse requires the "name" field to be present, even though
  // pubspec_overrides don't have one. So we inject a fake one.
  final pubspec = Pubspec.parse('''
name: tmp
$content
''');

  return pubspec.dependencyOverrides;
}