mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[web] Ignore changes in *.ttf files in felt build watch mode (#13634)
This commit is contained in:
parent
5b87cd0773
commit
f6e24a00cc
@ -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}');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user