Skip to content

Commit

Permalink
move examples and add smoke test for readme
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpr03 committed Mar 16, 2022
1 parent 18df78e commit be37120
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,5 @@ notify = { path = "." }
[workspace]
members = [
".",
"examples/hot_reload_tide",
"examples/watcher_kind"
"examples/hot_reload_tide"
]
2 changes: 1 addition & 1 deletion examples/hot_reload_tide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ tide = "0.16.0"
async-std = { version = "1.6.0", features = ["attributes"] }
serde_json = "1.0"
serde = "1.0.115"
notify = { version = "5.0.0-pre.14", features = ["serde"] }
notify = { path = "../../", features = ["serde"] }
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::time::Duration;
use notify::*;
fn main() {
let (tx, rx) = std::sync::mpsc::channel();
// example for using Watcher::kind to branch depending on what the default watcher currently is
let watcher: Box<dyn Watcher> = if RecommendedWatcher::kind() == WatcherKind::PollWatcher {
Box::new(PollWatcher::with_delay(tx, Duration::from_secs(1)).unwrap())
} else {
Expand Down
10 changes: 0 additions & 10 deletions examples/watcher_kind/Cargo.toml

This file was deleted.

24 changes: 24 additions & 0 deletions tests/readme_smoke_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
use std::path::Path;

fn main() -> notify::Result<()> {
let (tx, rx) = std::sync::mpsc::channel();

// Automatically select the best implementation for your platform.
// You can also access each implementation directly e.g. INotifyWatcher.
// Note that dropping this `watcher` will exit the Watcher-Loop itself.
let mut watcher = RecommendedWatcher::new(tx)?;

// Add a path to be watched. All files and directories at that path and
// below will be monitored for changes.
watcher.watch(Path::new("."), RecursiveMode::Recursive)?;

for res in rx {
match res {
Ok(event) => println!("changed: {:?}", event),
Err(e) => println!("watch error: {:?}", e),
}
}

Ok(())
}

0 comments on commit be37120

Please sign in to comment.