Only watch if 'watch' passed as argument
parent
079a581c69
commit
68209baa77
|
@ -45,17 +45,19 @@ fn build() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Watching...\n");
|
build();
|
||||||
|
|
||||||
|
if matches!(std::env::args().nth(1).as_deref(), Some("watch")) {
|
||||||
use notify::*;
|
use notify::*;
|
||||||
|
|
||||||
let (tx, rx) = std::sync::mpsc::channel();
|
let (tx, rx) = std::sync::mpsc::channel();
|
||||||
|
|
||||||
let mut watcher = watcher(tx, Duration::from_millis(100)).unwrap();
|
let mut watcher = watcher(tx, Duration::from_millis(100)).unwrap();
|
||||||
build();
|
|
||||||
|
|
||||||
watcher.watch("./src", RecursiveMode::Recursive).unwrap();
|
watcher.watch("./src", RecursiveMode::Recursive).unwrap();
|
||||||
|
|
||||||
|
println!();
|
||||||
|
log_info("Watching…\n");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match rx.recv() {
|
match rx.recv() {
|
||||||
Ok(_) => build(),
|
Ok(_) => build(),
|
||||||
|
@ -63,3 +65,4 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue