Skip to content

Commit 7d6e281

Browse files
authored
Merge pull request #117 from shaunbennett/master
Watch for file creation events in watch mode
2 parents 05e8f02 + 04d0f78 commit 7d6e281

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::verify::verify;
33
use clap::{crate_version, App, Arg, SubCommand};
44
use notify::DebouncedEvent;
55
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
6+
use std::ffi::OsStr;
67
use std::io::BufRead;
78
use std::sync::mpsc::channel;
89
use std::time::Duration;
@@ -85,8 +86,10 @@ fn watch() -> notify::Result<()> {
8586
loop {
8687
match rx.recv() {
8788
Ok(event) => match event {
88-
DebouncedEvent::Chmod(_) | DebouncedEvent::Write(_) => {
89-
let _ignored = verify();
89+
DebouncedEvent::Create(b) | DebouncedEvent::Chmod(b) | DebouncedEvent::Write(b) => {
90+
if b.extension() == Some(OsStr::new("rs")) {
91+
let _ignored = verify();
92+
}
9093
}
9194
_ => {}
9295
},

0 commit comments

Comments
 (0)