Add support for watching additional directories
This commit is contained in:
parent
1a0892745e
commit
fb0cbc90e3
|
@ -146,6 +146,10 @@ where
|
||||||
// Add the book.toml file to the watcher if it exists
|
// Add the book.toml file to the watcher if it exists
|
||||||
let _ = watcher.watch(book.root.join("book.toml"), NonRecursive);
|
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...");
|
info!("Listening for changes...");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -437,6 +437,8 @@ pub struct BuildConfig {
|
||||||
/// Should the default preprocessors always be used when they are
|
/// Should the default preprocessors always be used when they are
|
||||||
/// compatible with the renderer?
|
/// compatible with the renderer?
|
||||||
pub use_default_preprocessors: bool,
|
pub use_default_preprocessors: bool,
|
||||||
|
/// Extra directories to trigger rebuild when watching/serving
|
||||||
|
pub extra_watch_dirs: Vec<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BuildConfig {
|
impl Default for BuildConfig {
|
||||||
|
@ -445,6 +447,7 @@ impl Default for BuildConfig {
|
||||||
build_dir: PathBuf::from("book"),
|
build_dir: PathBuf::from("book"),
|
||||||
create_missing: true,
|
create_missing: true,
|
||||||
use_default_preprocessors: true,
|
use_default_preprocessors: true,
|
||||||
|
extra_watch_dirs: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -770,6 +773,7 @@ mod tests {
|
||||||
build_dir: PathBuf::from("outputs"),
|
build_dir: PathBuf::from("outputs"),
|
||||||
create_missing: false,
|
create_missing: false,
|
||||||
use_default_preprocessors: true,
|
use_default_preprocessors: true,
|
||||||
|
extra_watch_dirs: Vec::new(),
|
||||||
};
|
};
|
||||||
let rust_should_be = RustConfig { edition: None };
|
let rust_should_be = RustConfig { edition: None };
|
||||||
let playground_should_be = Playground {
|
let playground_should_be = Playground {
|
||||||
|
@ -980,6 +984,7 @@ mod tests {
|
||||||
build_dir: PathBuf::from("my-book"),
|
build_dir: PathBuf::from("my-book"),
|
||||||
create_missing: true,
|
create_missing: true,
|
||||||
use_default_preprocessors: true,
|
use_default_preprocessors: true,
|
||||||
|
extra_watch_dirs: Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let html_should_be = HtmlConfig {
|
let html_should_be = HtmlConfig {
|
||||||
|
|
Loading…
Reference in New Issue