File tree Expand file tree Collapse file tree 5 files changed +56
-23
lines changed Expand file tree Collapse file tree 5 files changed +56
-23
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,8 @@ Future<void> _runServer(
96
96
await runner.initialize;
97
97
98
98
final log = CliLogger ();
99
- final progress = log.progress ('Analyzing' );
99
+ final progress =
100
+ format == OutputFormatEnum .json ? null : log.progress ('Analyzing' );
100
101
101
102
await _runPlugins (
102
103
runner,
@@ -134,12 +135,12 @@ Future<void> _runServer(
134
135
Future <void > _runPlugins (
135
136
CustomLintRunner runner, {
136
137
required Logger log,
137
- required Progress progress,
138
138
required bool reload,
139
139
required Directory workingDirectory,
140
140
required bool fatalInfos,
141
141
required bool fatalWarnings,
142
142
required OutputFormatEnum format,
143
+ Progress ? progress,
143
144
}) async {
144
145
final lints = await runner.getLints (reload: reload);
145
146
Original file line number Diff line number Diff line change @@ -61,9 +61,12 @@ class CliLogger implements Logger {
61
61
Progress progress (String message) {
62
62
_cancelProgress ();
63
63
64
- final progress = ansi.useAnsi
65
- ? AnsiProgress (ansi, message)
66
- : SimpleProgress (this , message);
64
+ final progress = _LineOnFinishProgress (
65
+ ansi.useAnsi
66
+ ? AnsiProgress (ansi, message)
67
+ : SimpleProgress (this , message),
68
+ log: this ,
69
+ );
67
70
_currentProgress = progress;
68
71
return progress;
69
72
}
@@ -72,3 +75,29 @@ class CliLogger implements Logger {
72
75
@Deprecated ('This method will be removed in the future' )
73
76
void flush () {}
74
77
}
78
+
79
+ class _LineOnFinishProgress implements Progress {
80
+ const _LineOnFinishProgress (this .impl, {required this .log});
81
+
82
+ final CliLogger log;
83
+ final Progress impl;
84
+
85
+ @override
86
+ Duration get elapsed => impl.elapsed;
87
+
88
+ @override
89
+ String get message => impl.message;
90
+
91
+ @override
92
+ void cancel () {
93
+ impl.cancel ();
94
+ }
95
+
96
+ @override
97
+ void finish ({String ? message, bool showTiming = false }) {
98
+ impl.finish (message: message, showTiming: showTiming);
99
+
100
+ // Separate progress from results
101
+ log.stdout ('' );
102
+ }
103
+ }
Original file line number Diff line number Diff line change @@ -13,11 +13,11 @@ import 'output_format.dart';
13
13
void renderLints (
14
14
List <AnalysisErrorsParams > lints, {
15
15
required Logger log,
16
- required Progress progress,
17
16
required Directory workingDirectory,
18
17
required bool fatalInfos,
19
18
required bool fatalWarnings,
20
19
required OutputFormatEnum format,
20
+ Progress ? progress,
21
21
}) {
22
22
final OutputFormat outputFormat;
23
23
switch (format) {
@@ -69,10 +69,7 @@ void renderLints(
69
69
});
70
70
71
71
// Finish progress and display duration (only when ANSI is supported)
72
- progress.finish (showTiming: true );
73
-
74
- // Separate progress from results
75
- log.stdout ('' );
72
+ progress? .finish (showTiming: true );
76
73
77
74
outputFormat.render (
78
75
errors: errors,
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ No issues found!
208
208
}
209
209
],
210
210
});
211
- expect (process.stdout, 'Analyzing... \n\n $json \n ' );
211
+ expect (process.stdout, '$json \n ' );
212
212
} else {
213
213
expect (process.stdout, '''
214
214
Analyzing...
Original file line number Diff line number Diff line change @@ -154,8 +154,6 @@ void main() {
154
154
155
155
if (format == 'json' ) {
156
156
expect (process.stdout, '''
157
- Analyzing...
158
-
159
157
{"version":1,"diagnostics":[]}
160
158
''' );
161
159
} else {
@@ -202,24 +200,32 @@ No issues found!
202
200
final err = process.stderr.map (utf8.decode);
203
201
204
202
expect (err, emitsDone);
205
- expect (
206
- out.join (),
207
- completion (
208
- allOf (
209
- startsWith ('Analyzing...' ),
210
- format == 'json'
211
- ? endsWith ('${jsonLints (app .resolveSymbolicLinksSync ())}\n ' )
212
- : endsWith ('''
203
+
204
+ if (format == 'json' ) {
205
+ expect (
206
+ out.join (),
207
+ completion (
208
+ equals ('${jsonLints (app .resolveSymbolicLinksSync ())}\n ' ),
209
+ ),
210
+ );
211
+ } else {
212
+ expect (
213
+ out.join (),
214
+ completion (
215
+ allOf (
216
+ startsWith ('Analyzing...' ),
217
+ endsWith ('''
213
218
lib/another.dart:1:6 • Hello world • hello_world • INFO
214
219
lib/another.dart:1:6 • Oy • oy • INFO
215
220
lib/main.dart:1:6 • Hello world • hello_world • INFO
216
221
lib/main.dart:1:6 • Oy • oy • INFO
217
222
218
223
4 issues found.
219
224
''' ),
225
+ ),
220
226
),
221
- ),
222
- );
227
+ );
228
+ }
223
229
expect (await process.exitCode, 1 );
224
230
});
225
231
});
You can’t perform that action at this time.
0 commit comments