Skip to content

Commit

Permalink
Do not complete future if already completed; better handle null messages
Browse files Browse the repository at this point in the history
  • Loading branch information
smaifullerton-wk committed Jun 13, 2019
1 parent 49593cf commit f4040ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/src/dart_dev_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ Future _run(List<String> args) async {

reporter.log('');
if (result.successful) {
reporter.success(result.message ?? '', shout: true);
reporter.success(result.message, shout: true);
} else {
reporter.error(result.message ?? 'The task did not succeed.', shout: true);
reporter.error(result.message, shout: true);
exitCode = 1;
}
}
9 changes: 8 additions & 1 deletion lib/src/reporter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,26 @@ class Reporter {
}

void error(String message, {bool shout: false}) {
message = message ?? 'An error was encountered running the task.';
_log(stderr, colorRed(message), shout: shout);
}

void success(String message, {bool shout: false}) {
if (message == null) {
return;
}
log(colorGreen(message), shout: shout);
}

void warning(String message, {bool shout: false}) {
if (message == null) {
return;
}
_log(stderr, colorYellow(message), shout: shout);
}

String _colorMessage(AnsiPen pen, String message) =>
color && message.isNotEmpty ? pen(message) : message;
color && message != null && message.isNotEmpty ? pen(message) : message;

void _log(IOSink sink, String message, {bool shout: false}) {
if (quiet && !shout) return;
Expand Down
6 changes: 4 additions & 2 deletions lib/src/tasks/test/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ TestTask test({
task.successful = code <= 0;

if (!task.successful) {
task.testSummary = 'An error was encountered when running tests.';
// task.testSummary = 'An error was encountered when running tests.';
}

outputProcessed.complete();
if (!outputProcessed.isCompleted) {
outputProcessed.complete();
}
}
});

Expand Down

0 comments on commit f4040ee

Please sign in to comment.