summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorkomaeda <819880950@qq.com>2019-03-06 20:28:29 +0100
committerGitHub <noreply@github.com>2019-03-06 20:28:29 +0100
commit7d6e2812fb7b22ff673f753cfc2a7c44fa1c57b8 (patch)
tree318ec87de2625fd2b4038125a1acfd7f61e5b0fe /src/main.rs
parent05e8f02d0aeef9d9c2447ec642a5c3664c9f47a0 (diff)
parent04d0f78a2c3f326eae80c92ee6c83765bd4ce11e (diff)
Merge pull request #117 from shaunbennett/master
Watch for file creation events in watch mode
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 8f9ccea..de13f1c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,6 +3,7 @@ use crate::verify::verify;
use clap::{crate_version, App, Arg, SubCommand};
use notify::DebouncedEvent;
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
+use std::ffi::OsStr;
use std::io::BufRead;
use std::sync::mpsc::channel;
use std::time::Duration;
@@ -85,8 +86,10 @@ fn watch() -> notify::Result<()> {
loop {
match rx.recv() {
Ok(event) => match event {
- DebouncedEvent::Chmod(_) | DebouncedEvent::Write(_) => {
- let _ignored = verify();
+ DebouncedEvent::Create(b) | DebouncedEvent::Chmod(b) | DebouncedEvent::Write(b) => {
+ if b.extension() == Some(OsStr::new("rs")) {
+ let _ignored = verify();
+ }
}
_ => {}
},