diff --git a/lib/web_ui/dev/build.dart b/lib/web_ui/dev/build.dart index 541710d74d1..86c462e77ec 100644 --- a/lib/web_ui/dev/build.dart +++ b/lib/web_ui/dev/build.dart @@ -60,6 +60,8 @@ class BuildCommand extends Command { PipelineWatcher( dir: libPath.absolute, pipeline: buildPipeline, + // Ignore font files that are copied whenever tests run. + ignore: (event) => event.path.endsWith('.ttf'), ).start(); // Return a never-ending future. return Completer().future; @@ -143,10 +145,13 @@ class Pipeline { } } +typedef WatchEventPredicate = bool Function(WatchEvent event); + class PipelineWatcher { PipelineWatcher({ @required this.dir, @required this.pipeline, + this.ignore, }) : watcher = DirectoryWatcher(dir); /// The path of the directory to watch for changes. @@ -158,6 +163,10 @@ class PipelineWatcher { /// Used to watch a directory for any file system changes. final DirectoryWatcher watcher; + /// A callback that determines whether to rerun the pipeline or not for a + /// given [WatchEvent] instance. + final WatchEventPredicate ignore; + void start() { watcher.events.listen(_onEvent); } @@ -166,6 +175,10 @@ class PipelineWatcher { Timer _scheduledPipeline; void _onEvent(WatchEvent event) { + if (ignore != null && ignore(event)) { + return; + } + final String relativePath = path.relative(event.path, from: dir); print('- [${event.type}] ${relativePath}');