From 8ee795045af4fcf3c464bdbe43d9b8a814bf5a01 Mon Sep 17 00:00:00 2001 From: Michael Bryan Date: Sat, 9 Dec 2017 20:36:23 +1100 Subject: [PATCH 1/2] Added a quick fix so if the config isn't found we use a default --- src/book/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/book/mod.rs b/src/book/mod.rs index 2993f3df..05d45d9c 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -299,8 +299,13 @@ impl MDBook { pub fn read_config(mut self) -> Result { let config_path = self.root.join("book.toml"); - debug!("[*] Loading the config from {}", config_path.display()); - self.config = Config::from_disk(&config_path)?; + + if config_path.exists() { + debug!("[*] Loading the config from {}", config_path.display()); + self.config = Config::from_disk(&config_path)?; + } else { + self.config = Config::default(); + } Ok(self) } From 42ff5a895c55901ba5888bdf069926eaa40fb4ca Mon Sep 17 00:00:00 2001 From: Michael Bryan Date: Sat, 9 Dec 2017 20:46:39 +1100 Subject: [PATCH 2/2] Added a test to make sure book.toml isn't required --- tests/init.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/init.rs b/tests/init.rs index e35edee6..32c0ce8d 100644 --- a/tests/init.rs +++ b/tests/init.rs @@ -51,3 +51,14 @@ fn run_mdbook_init_with_custom_book_and_src_locations() { assert!(target.exists(), "{} should have been created by `mdbook init`", file); } } + +#[test] +fn book_toml_isnt_required() { + let temp = TempDir::new("mdbook").unwrap(); + let mut md = MDBook::new(temp.path()); + md.init().unwrap(); + + assert!(!temp.path().join("book.toml").exists()); + + md.read_config().unwrap().build().unwrap(); +}