Pubspec.load constructor
Pubspec.load(
- Directory directory
Implementation
factory Pubspec.load(Directory directory) {
bool isPubspecFile(File file) => p.basename(file.path) == Pubspec.filename;
final pubspecFile = directory.listSync().whereType<File>().firstWhere(
isPubspecFile,
orElse: () => throw RpsException(
'Cannot find pubspec.yaml file in the current directory '
'(${Directory.current.path}).',
),
);
try {
final pubspecString = pubspecFile.readAsStringSync();
final parsed = Map.unmodifiable(loadYaml(pubspecString));
return Pubspec._(directory, parsed);
} on Exception catch (err, st) {
throw RpsException('Pubspec file cannot be parsed', err, st);
}
}