Skip to content

Commit aced9b1

Browse files
committed
if the lockfile is deleted, stop running the watcher
1 parent 391f785 commit aced9b1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

rewatch/src/watcher.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ async fn async_watch(
9292
}
9393

9494
for event in events {
95+
// if there is a file named rewatch.lock in the events path, we can quit the watcher
96+
if let Some(path) = event.paths.iter().find(|path| path.ends_with("rewatch.lock")) {
97+
match event.kind {
98+
EventKind::Remove(_) => {
99+
if show_progress {
100+
println!("\nExiting... (lockfile removed)");
101+
}
102+
clean::cleanup_after_build(&build_state);
103+
return Ok(());
104+
}
105+
_ => (),
106+
}
107+
}
108+
95109
let paths = event
96110
.paths
97111
.iter()

0 commit comments

Comments
 (0)