未验证 提交 f6e24a00 编写于 作者: M Mouad Debbar 提交者: GitHub

[web] Ignore changes in *.ttf files in felt build watch mode (#13634)

上级 5b87cd07
......@@ -60,6 +60,8 @@ class BuildCommand extends Command<bool> {
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<bool>().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}');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册