updateVersion method

  1. @override
Future<void> updateVersion(
  1. String newVersion
)
override

Implementation

@override
Future<void> updateVersion(String newVersion) async {
  final file = File('pubspec.yaml');
  if (!file.existsSync()) {
    logger.error('pubspec.yaml not found');
    throw Exception('pubspec.yaml not found');
  }

  final content = file.readAsStringSync();
  final updated = content.replaceFirst(
    RegExp(r'version:\s*.*'),
    'version: $newVersion',
  );
  file.writeAsStringSync(updated);
  logger.info('Updated pubspec.yaml to version $newVersion');
}