From fb0cbc90e356fa83e9cf153b5d6ec7c2f2069407 Mon Sep 17 00:00:00 2001 From: Will Crichton Date: Fri, 28 Oct 2022 11:13:33 -0700 Subject: [PATCH] Add support for watching additional directories --- src/cmd/watch.rs | 4 ++++ src/config.rs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index 9336af77..f5cf37f8 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -146,6 +146,10 @@ where // Add the book.toml file to the watcher if it exists let _ = watcher.watch(book.root.join("book.toml"), NonRecursive); + for dir in &book.config.build.extra_watch_dirs { + let _ = watcher.watch(dir, Recursive); + } + info!("Listening for changes..."); loop { diff --git a/src/config.rs b/src/config.rs index b7d03d1a..7f4adc42 100644 --- a/src/config.rs +++ b/src/config.rs @@ -437,6 +437,8 @@ pub struct BuildConfig { /// Should the default preprocessors always be used when they are /// compatible with the renderer? pub use_default_preprocessors: bool, + /// Extra directories to trigger rebuild when watching/serving + pub extra_watch_dirs: Vec, } impl Default for BuildConfig { @@ -445,6 +447,7 @@ impl Default for BuildConfig { build_dir: PathBuf::from("book"), create_missing: true, use_default_preprocessors: true, + extra_watch_dirs: Vec::new(), } } } @@ -770,6 +773,7 @@ mod tests { build_dir: PathBuf::from("outputs"), create_missing: false, use_default_preprocessors: true, + extra_watch_dirs: Vec::new(), }; let rust_should_be = RustConfig { edition: None }; let playground_should_be = Playground { @@ -980,6 +984,7 @@ mod tests { build_dir: PathBuf::from("my-book"), create_missing: true, use_default_preprocessors: true, + extra_watch_dirs: Vec::new(), }; let html_should_be = HtmlConfig {