readPubspec static method

Future<PubspecData> readPubspec()

Read and parse pubspec.yaml file

Implementation

static Future<PubspecData> readPubspec() async {
  final file = File(FileConfig.pubspecFile);

  if (!file.existsSync()) {
    throw Exception('${FileConfig.pubspecFile} not found');
  }

  final content = await file.readAsString();
  final yaml = loadYaml(content) as Map;

  return PubspecData(
    originalContent: content,
    yaml: yaml,
  );
}