fix: use stderr/stdout instead of print in version tool

This commit is contained in:
bponders12-cell 2026-08-31 22:03:32 -04:00
parent 77a54401fc
commit d9d549ceb3
1 changed files with 7 additions and 7 deletions

View File

@ -1,15 +1,15 @@
import 'dart:io'; import 'dart:io';
void main(List<String> args) { void main(List<String> args) {
if (args.isEmpty) { if (args.isEmpty) {
print('Usage: dart run tool/bump_version.dart <patch|minor|major|build>'); stderr.writeln('Usage: dart run tool/bump_version.dart <patch|minor|major|build>');
exit(1); exit(1);
} }
final action = args[0].toLowerCase(); final action = args[0].toLowerCase();
final pubspecFile = File('pubspec.yaml'); final pubspecFile = File('pubspec.yaml');
if (!pubspecFile.existsSync()) { if (!pubspecFile.existsSync()) {
print('Error: pubspec.yaml not found.'); stderr.writeln('Error: pubspec.yaml not found.');
exit(1); exit(1);
} }
@ -18,7 +18,7 @@ void main(List<String> args) {
final match = versionRegex.firstMatch(pubspecContent); final match = versionRegex.firstMatch(pubspecContent);
if (match == null) { if (match == null) {
print('Error: could not find version pattern in pubspec.yaml'); stderr.writeln('Error: could not find version pattern in pubspec.yaml');
exit(1); exit(1);
} }
@ -47,12 +47,12 @@ void main(List<String> args) {
build++; build++;
break; break;
default: default:
print('Unknown action "$action". Use patch, minor, major, or build.'); stderr.writeln('Unknown action "$action". Use patch, minor, major, or build.');
exit(1); exit(1);
} }
final newVersion = '$major.$minor.$patch+$build'; final newVersion = '$major.$minor.$patch+$build';
print('Bumping version to: $newVersion'); stdout.writeln('Bumping version to: $newVersion');
final updatedPubspec = pubspecContent.replaceFirst(versionRegex, 'version: $newVersion'); final updatedPubspec = pubspecContent.replaceFirst(versionRegex, 'version: $newVersion');
pubspecFile.writeAsStringSync(updatedPubspec); pubspecFile.writeAsStringSync(updatedPubspec);
@ -65,5 +65,5 @@ void main(List<String> args) {
appInfoFile.writeAsStringSync(updatedAppInfo); appInfoFile.writeAsStringSync(updatedAppInfo);
} }
print('Successfully updated pubspec.yaml and lib/core/app_info.dart to $newVersion'); stdout.writeln('Successfully updated pubspec.yaml and lib/core/app_info.dart to $newVersion');
} }