Skip to content

Commit 7e83a55

Browse files
committed
feat(core): ignore more directories from watcher
1 parent 184723e commit 7e83a55

File tree

3 files changed

+134
-16
lines changed

3 files changed

+134
-16
lines changed

Cargo.lock

Lines changed: 128 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shared/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ tracing-subscriber = { version = "0.3.9", features = ["env-filter"]}
2626
tracing-appender = "0.2.1"
2727

2828
notify = "5.0.0-pre.13"
29+
wax = "0.4.0"

shared/src/watch.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use notify::{RecursiveMode, Watcher};
44
use std::path::Path;
55
use tokio::sync::mpsc;
66
use tracing::{debug, info, trace};
7+
use wax::{Glob, Pattern};
78

89
// TODO: Stop handle
910

@@ -32,6 +33,9 @@ pub async fn update(state: SharedState, _msg: Command) {
3233
}
3334

3435
fn new(state: SharedState, root: String) -> tokio::task::JoinHandle<anyhow::Result<()>> {
36+
// NOTE: should watch for registerd directories?
37+
let ignore = wax::any::<Glob, _>(["**/.git/**", "**/*.xcodeproj/**", "**/.*"]).unwrap();
38+
3539
tokio::spawn(async move {
3640
let (tx, mut rx) = mpsc::channel(100);
3741
// FIXME: Sometimes (more then one/duplicated) event is processed at the same time
@@ -55,8 +59,7 @@ fn new(state: SharedState, root: String) -> tokio::task::JoinHandle<anyhow::Resu
5559
None => continue,
5660
};
5761

58-
// NOTE: should watch for registerd directories?
59-
if path.to_str().unwrap().contains(".git") {
62+
if ignore.is_match(path.to_str().unwrap()) {
6063
continue;
6164
}
6265

0 commit comments

Comments
 (0)