Skip to content

Commit

Permalink
feat(shorebird_cli): shorebird init report progress when detecting …
Browse files Browse the repository at this point in the history
…flavors (#549)
  • Loading branch information
felangel authored May 25, 2023
1 parent 2b8a406 commit 75bce9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/shorebird_cli/lib/src/commands/init_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ If you want to reinitialize Shorebird, please run "shorebird init --force".''');
}

var productFlavors = <String>{};
final detectFlavorsProgress = logger.progress('Detecting product flavors');
try {
productFlavors = await extractProductFlavors(Directory.current.path);
detectFlavorsProgress.complete();
} catch (error) {
detectFlavorsProgress.fail();
logger.detail('Unable to extract product flavors: $error');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class _MockCodePushClient extends Mock implements CodePushClient {}

class _MockLogger extends Mock implements Logger {}

class _MockProgress extends Mock implements Progress {}

class _MockProcess extends Mock implements ShorebirdProcess {}

class _MockProcessResult extends Mock implements ShorebirdProcessResult {}
Expand All @@ -48,6 +50,7 @@ environment:
late ShorebirdProcessResult result;
late CodePushClient codePushClient;
late Logger logger;
late Progress progress;
late InitCommand command;

setUp(() {
Expand All @@ -58,6 +61,7 @@ environment:
result = _MockProcessResult();
codePushClient = _MockCodePushClient();
logger = _MockLogger();
progress = _MockProgress();
command = InitCommand(
auth: auth,
buildCodePushClient: ({
Expand All @@ -83,6 +87,7 @@ environment:
when(
() => logger.prompt(any(), defaultValue: any(named: 'defaultValue')),
).thenReturn(appName);
when(() => logger.progress(any())).thenReturn(progress);
when(
() => process.run(
any(),
Expand Down Expand Up @@ -317,6 +322,7 @@ If you want to reinitialize Shorebird, please run "shorebird init --force".''',
command.run,
getCurrentDirectory: () => tempDir,
);
verify(() => logger.progress('Detecting product flavors')).called(1);
verify(
() => logger.detail(
'Unable to extract product flavors: Exception: error\noops',
Expand Down

0 comments on commit 75bce9d

Please sign in to comment.