From e00b8835cca59da9f3aca9e267eaa65ff877078f Mon Sep 17 00:00:00 2001 From: riverbl <94326797+riverbl@users.noreply.github.com> Date: Fri, 28 Jul 2023 18:19:56 +0100 Subject: [PATCH] Fix issues with extra-watch-dirs Fix paths specified in extra-watch-dirs being relative to the current working directory rather than the book root If there is an error canonicalising paths in extra-watch-dirs, log the error and exit rather than panicking --- src/cmd/watch.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index e9806e1c..9fd5085d 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -130,11 +130,16 @@ where let _ = watcher.watch(&book.root.join("book.toml"), NonRecursive); for dir in &book.config.build.extra_watch_dirs { - let path = dir.canonicalize().unwrap(); - if let Err(e) = watcher.watch(&path, Recursive) { + let path = book.root.join(dir); + let canonical_path = path.canonicalize().unwrap_or_else(|e| { + error!("Error while watching extra directory {path:?}:\n {e}"); + std::process::exit(1); + }); + + if let Err(e) = watcher.watch(&canonical_path, Recursive) { error!( "Error while watching extra directory {:?}:\n {:?}", - path, e + canonical_path, e ); std::process::exit(1); }