Skip to content

Commit

Permalink
improve cli logging for failed first builds during serve
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilian Schulte committed Sep 28, 2024
1 parent ab17b3d commit ba06191
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions packages/jaspr_cli/lib/src/commands/serve_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ class ServeCommand extends BaseCommand with ProxyHelper, FlutterHelper {
} else if (event.status == BuildStatus.failed) {
logger.write('Failed building web assets. There is probably more output above.',
level: Level.error, progress: ProgressState.completed);
if (!buildCompleter.isCompleted) {
buildCompleter.completeError(event);
}
} else if (event.status == BuildStatus.started) {
if (buildCompleter.isCompleted) {
logger.write('Rebuilding web assets...', progress: ProgressState.running);
Expand All @@ -241,11 +244,16 @@ class ServeCommand extends BaseCommand with ProxyHelper, FlutterHelper {
}
});

await buildCompleter.future;
try {
await buildCompleter.future;
logger.write('Done building web assets.', progress: ProgressState.completed);
} on BuildResult catch (_) {
logger.write('Could not start dev server due to build errors.',
level: Level.error, progress: ProgressState.completed);
await shutdown();
}
timer.cancel();

logger.write('Done building web assets.', progress: ProgressState.completed);

return workflow;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jaspr_cli/lib/src/logging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Logger {
}
}

void write(String message, {Tag tag = Tag.none, Level level = Level.info, ProgressState? progress}) {
void write(String message, {Tag tag = Tag.cli, Level level = Level.info, ProgressState? progress}) {
if (level == Level.verbose && !verbose) {
return;
}
Expand Down

0 comments on commit ba06191

Please sign in to comment.