getPubspecYaml function
Get the pubspec.yaml file
Implementation
Pubspec getPubspecYaml(Directory projectDir) {
final pubspec = File('${projectDir.path}/pubspec.yaml');
// coverage:ignore-start
if (_pubspecCache.containsKey(pubspec)) {
return _pubspecCache[pubspec]!;
}
// coverage:ignore-end
late Pubspec pubspecYaml;
final pubspecContent = pubspec.readAsStringSync();
try {
pubspecYaml = Pubspec.parse(pubspecContent);
_pubspecCache[pubspec] = pubspecYaml;
} catch (e) {
throw Exception(red('Error parsing pubspec.yaml:') + e.toString());
}
return pubspecYaml;
}