writePubspecVersion function

Future<void> writePubspecVersion(
  1. String filePath,
  2. String version
)

Writes the version field to a pubspec.yaml file, preserving all other content (including comments and formatting).

Implementation

Future<void> writePubspecVersion(String filePath, String version) async {
  final file = File(filePath);
  await file.writeAsString(
    renderPubspecVersion(await file.readAsString(), version),
  );
}