Use `printError`

This commit is contained in:
shilangyu 2021-03-01 09:55:30 +01:00
parent 5c989679b6
commit 171c18cc6c
3 changed files with 4 additions and 9 deletions

View File

@ -13,7 +13,7 @@ void confirm(String message) {
} }
} }
void printError(String message, {bool shouldExit = false}) { void printError(String message, {bool shouldExit = true}) {
stderr.writeln('\x1B[31m$message\x1B[0m'); stderr.writeln('\x1B[31m$message\x1B[0m');
if (shouldExit) exit(1); if (shouldExit) exit(1);

View File

@ -199,10 +199,7 @@ void portStrings(
final renamedKey = extract.value ?? key; final renamedKey = extract.value ?? key;
if (!lemmyTranslations[baseLanguage].containsKey(key)) { if (!lemmyTranslations[baseLanguage].containsKey(key)) {
printError( printError('"$key" does not exist in $repoName');
'"$key" does not exist in $repoName',
shouldExit: true,
);
} }
if (lemmurTranslations[baseLanguage].containsKey(key) && !force) { if (lemmurTranslations[baseLanguage].containsKey(key) && !force) {

View File

@ -7,8 +7,7 @@ Future<void> main(List<String> args) async {
await assertNoStagedGit(); await assertNoStagedGit();
if (args.isEmpty || !{'patch', 'minor', 'major'}.contains(args[0])) { if (args.isEmpty || !{'patch', 'minor', 'major'}.contains(args[0])) {
print('Unknown version bump type'); printError('Unknown version bump type');
exit(1);
} }
final version = await bumpedVersion(args[0]); final version = await bumpedVersion(args[0]);
@ -28,8 +27,7 @@ Future<void> assertNoStagedGit() async {
await Process.run('git', ['diff-index', '--cached', '--quiet', 'HEAD']); await Process.run('git', ['diff-index', '--cached', '--quiet', 'HEAD']);
if (res.exitCode != 0) { if (res.exitCode != 0) {
print('You have staged files, commit or unstage them.'); printError('You have staged files, commit or unstage them.');
exit(1);
} }
} }