projectPubspec property

FutureOr<Map<String, dynamic>> get projectPubspec

The resolved project pubspec.yaml Map.

Implementation

FutureOr<Map<String, dynamic>> get projectPubspec {
  var pubspec = _pubspec;
  if (pubspec == null) {
    return projectPubspecFile.resolveMapped((file) {
      if (!file.existsSync()) {
        throw StateError(
            'Failed to locate `pubspec.yaml` in project directory `$projectDirectory`');
      }

      var content = file.readAsStringSync();
      final yaml = loadYaml(content) as YamlMap;
      var pubspec = yaml.cast<String, dynamic>();

      _pubspec = pubspec;

      log('INFO', 'Resolved `projectPubspec`: ${pubspec.length} entries');

      return pubspec;
    });
  } else {
    return pubspec;
  }
}