fix(shorebird_cli): shorebird init error logs formatting (#168)

This commit is contained in:
Felix Angelov
2023-03-24 17:09:34 -05:00
committed by GitHub
parent 1893a0d55d
commit 9873dfedbd
2 changed files with 10 additions and 8 deletions
@@ -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 {
@@ -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);
});