updateVersion method
void
updateVersion(
- String projectPath,
- ProjectVersion newVersion, {
- bool dryRun = false,
- TerminalOutput? output,
Writes newVersion into pubspec.yaml inside projectPath unless dryRun is true.
Implementation
void updateVersion(
String projectPath,
ProjectVersion newVersion, {
bool dryRun = false,
TerminalOutput? output,
}) {
final pubspecFile = File('$projectPath/pubspec.yaml');
final current = _pubspecHandler.readVersion(pubspecFile);
if (current == newVersion) {
output?.info('Version unchanged: $current');
return;
}
if (dryRun) {
output?.info(
'[DRY-RUN] Would update pubspec.yaml version: $current -> $newVersion');
return;
}
_pubspecHandler.writeVersion(pubspecFile, newVersion);
output?.success('Updated pubspec.yaml version: $current -> $newVersion');
}