@@ -27,7 +27,7 @@ class BuildCommand extends Command<bool> {
27
27
String get name => 'build' ;
28
28
29
29
@override
30
- String get description => 'Build the web engine package .' ;
30
+ String get description => 'Build the Flutter web engine.' ;
31
31
32
32
bool get isWatchMode => argResults['watch' ];
33
33
@@ -141,18 +141,16 @@ class PipelineWatcher {
141
141
}
142
142
143
143
int _pipelineRunCount = 0 ;
144
- bool _pipelineScheduled = false ;
144
+ Timer _scheduledPipeline ;
145
145
146
146
void _onEvent (WatchEvent event) {
147
147
final String relativePath = path.relative (event.path, from: dir);
148
148
print ('- [${event .type }] ${relativePath }' );
149
- if (_pipelineScheduled) {
150
- return ;
151
- }
149
+
152
150
_pipelineRunCount++ ;
153
- _pipelineScheduled = true ;
154
- Future . delayed (const Duration (milliseconds: 100 )). then ((_ ) {
155
- _pipelineScheduled = false ;
151
+ _scheduledPipeline ? . cancel () ;
152
+ _scheduledPipeline = Timer (const Duration (milliseconds: 100 ), ( ) {
153
+ _scheduledPipeline = null ;
156
154
_runPipeline ();
157
155
});
158
156
}
@@ -163,11 +161,7 @@ class PipelineWatcher {
163
161
case PipelineStatus .started:
164
162
pipeline.stop ().then ((_) {
165
163
runCount = _pipelineRunCount;
166
- return pipeline.start ();
167
- }).then ((_) {
168
- if (runCount == _pipelineRunCount) {
169
- print ('*** Done! ***' );
170
- }
164
+ pipeline.start ().then ((_) => _pipelineDone (runCount));
171
165
});
172
166
break ;
173
167
@@ -177,12 +171,14 @@ class PipelineWatcher {
177
171
178
172
default :
179
173
runCount = _pipelineRunCount;
180
- pipeline.start ().then ((_) {
181
- if (runCount == _pipelineRunCount) {
182
- print ('Done!' );
183
- }
184
- });
174
+ pipeline.start ().then ((_) => _pipelineDone (runCount));
185
175
break ;
186
176
}
187
177
}
178
+
179
+ void _pipelineDone (int pipelineRunCount) {
180
+ if (pipelineRunCount == _pipelineRunCount) {
181
+ print ('*** Done! ***' );
182
+ }
183
+ }
188
184
}
0 commit comments