Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,17 @@ pub fn generate(
if watch {
let mut hotwatch = Hotwatch::new().expect("Failed to initialize hotwatch!");
let watch_folder = Arc::clone(input_folder).as_path().to_path_buf();
let out_folder = Arc::clone(output_folder).as_path().to_path_buf();
// Watch the input folder for changes
hotwatch
.watch(watch_folder, move |event: Event| match event.kind {
EventKind::Create(_) | EventKind::Modify(_) | EventKind::Remove(_) => {
info!("Change detected. Rebuilding site...");
rebuild();
for ev in event.paths.iter() {
if !ev.starts_with(fs::canonicalize(out_folder.clone()).unwrap()) {
info!("Change detected. Rebuilding site...");
rebuild();
}
}
}
_ => {}
})
Expand Down