From 9873dfedbd376fc8a468b310b38251353aec6d2c Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Fri, 24 Mar 2023 17:09:34 -0500 Subject: [PATCH] fix(shorebird_cli): `shorebird init` error logs formatting (#168) --- .../shorebird_cli/lib/src/commands/init_command.dart | 8 ++++---- .../test/src/commands/init_command_test.dart | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/shorebird_cli/lib/src/commands/init_command.dart b/packages/shorebird_cli/lib/src/commands/init_command.dart index 43822590..f8b59723 100644 --- a/packages/shorebird_cli/lib/src/commands/init_command.dart +++ b/packages/shorebird_cli/lib/src/commands/init_command.dart @@ -30,11 +30,11 @@ class InitCommand extends ShorebirdCommand final progress = logger.progress('Initializing Shorebird'); try { if (!hasPubspecYaml) { - logger.err('Could not find a "pubspec.yaml".'); + progress.fail('Could not find a "pubspec.yaml".'); return ExitCode.noInput.code; } } catch (error) { - logger.err('Error parsing "pubspec.yaml": $error'); + progress.fail('Error parsing "pubspec.yaml": $error'); return ExitCode.software.code; } @@ -42,7 +42,7 @@ class InitCommand extends ShorebirdCommand try { shorebirdYamlExists = hasShorebirdYaml; } catch (_) { - logger.err('Error parsing "shorebird.yaml".'); + progress.fail('Error parsing "shorebird.yaml".'); return ExitCode.software.code; } @@ -52,7 +52,7 @@ class InitCommand extends ShorebirdCommand final app = await createApp(); appId = app.id; } catch (error) { - logger.err('$error'); + progress.fail('$error'); return ExitCode.software.code; } } else { diff --git a/packages/shorebird_cli/test/src/commands/init_command_test.dart b/packages/shorebird_cli/test/src/commands/init_command_test.dart index 4dc66474..fdce1db8 100644 --- a/packages/shorebird_cli/test/src/commands/init_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/init_command_test.dart @@ -72,7 +72,7 @@ environment: command.run, getCurrentDirectory: () => tempDir, ); - verify(() => logger.err('Could not find a "pubspec.yaml".')).called(1); + verify(() => progress.fail('Could not find a "pubspec.yaml".')).called(1); expect(exitCode, ExitCode.noInput.code); }); @@ -84,7 +84,9 @@ environment: getCurrentDirectory: () => tempDir, ); verify( - () => logger.err(any(that: contains('Error parsing "pubspec.yaml":'))), + () => progress.fail( + any(that: contains('Error parsing "pubspec.yaml":')), + ), ).called(1); expect(exitCode, ExitCode.software.code); }); @@ -105,7 +107,7 @@ environment: verify( () => logger.prompt(any(), defaultValue: any(named: 'defaultValue')), ).called(1); - verify(() => logger.err('$error')).called(1); + verify(() => progress.fail('$error')).called(1); expect(exitCode, ExitCode.software.code); }); @@ -120,7 +122,7 @@ environment: getCurrentDirectory: () => tempDir, ); verify( - () => logger.err('Error parsing "shorebird.yaml".'), + () => progress.fail('Error parsing "shorebird.yaml".'), ).called(1); expect(exitCode, ExitCode.software.code); });