Skip to content

Commit fb0cbc9

Browse files
committed
Add support for watching additional directories
1 parent 1a08927 commit fb0cbc9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/cmd/watch.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ where
146146
// Add the book.toml file to the watcher if it exists
147147
let _ = watcher.watch(book.root.join("book.toml"), NonRecursive);
148148

149+
for dir in &book.config.build.extra_watch_dirs {
150+
let _ = watcher.watch(dir, Recursive);
151+
}
152+
149153
info!("Listening for changes...");
150154

151155
loop {

src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ pub struct BuildConfig {
437437
/// Should the default preprocessors always be used when they are
438438
/// compatible with the renderer?
439439
pub use_default_preprocessors: bool,
440+
/// Extra directories to trigger rebuild when watching/serving
441+
pub extra_watch_dirs: Vec<PathBuf>,
440442
}
441443

442444
impl Default for BuildConfig {
@@ -445,6 +447,7 @@ impl Default for BuildConfig {
445447
build_dir: PathBuf::from("book"),
446448
create_missing: true,
447449
use_default_preprocessors: true,
450+
extra_watch_dirs: Vec::new(),
448451
}
449452
}
450453
}
@@ -770,6 +773,7 @@ mod tests {
770773
build_dir: PathBuf::from("outputs"),
771774
create_missing: false,
772775
use_default_preprocessors: true,
776+
extra_watch_dirs: Vec::new(),
773777
};
774778
let rust_should_be = RustConfig { edition: None };
775779
let playground_should_be = Playground {
@@ -980,6 +984,7 @@ mod tests {
980984
build_dir: PathBuf::from("my-book"),
981985
create_missing: true,
982986
use_default_preprocessors: true,
987+
extra_watch_dirs: Vec::new(),
983988
};
984989

985990
let html_should_be = HtmlConfig {

0 commit comments

Comments
 (0)