Skip to content

Commit dc89a82

Browse files
Merge pull request #506 from Michael-F-Bryan/quickfix
Added a quick fix so if the config isn't found we use a default
2 parents f22835f + 42ff5a8 commit dc89a82

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/book/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,13 @@ impl MDBook {
299299
300300
pub fn read_config(mut self) -> Result<Self> {
301301
let config_path = self.root.join("book.toml");
302-
debug!("[*] Loading the config from {}", config_path.display());
303-
self.config = Config::from_disk(&config_path)?;
302+
303+
if config_path.exists() {
304+
debug!("[*] Loading the config from {}", config_path.display());
305+
self.config = Config::from_disk(&config_path)?;
306+
} else {
307+
self.config = Config::default();
308+
}
304309

305310
Ok(self)
306311
}

tests/init.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,14 @@ fn run_mdbook_init_with_custom_book_and_src_locations() {
5151
assert!(target.exists(), "{} should have been created by `mdbook init`", file);
5252
}
5353
}
54+
55+
#[test]
56+
fn book_toml_isnt_required() {
57+
let temp = TempDir::new("mdbook").unwrap();
58+
let mut md = MDBook::new(temp.path());
59+
md.init().unwrap();
60+
61+
assert!(!temp.path().join("book.toml").exists());
62+
63+
md.read_config().unwrap().build().unwrap();
64+
}

0 commit comments

Comments
 (0)