Merge pull request #506 from Michael-F-Bryan/quickfix
Added a quick fix so if the config isn't found we use a default
This commit is contained in:
commit
dc89a82329
|
@ -299,8 +299,13 @@ impl MDBook {
|
||||||
|
|
||||||
pub fn read_config(mut self) -> Result<Self> {
|
pub fn read_config(mut self) -> Result<Self> {
|
||||||
let config_path = self.root.join("book.toml");
|
let config_path = self.root.join("book.toml");
|
||||||
|
|
||||||
|
if config_path.exists() {
|
||||||
debug!("[*] Loading the config from {}", config_path.display());
|
debug!("[*] Loading the config from {}", config_path.display());
|
||||||
self.config = Config::from_disk(&config_path)?;
|
self.config = Config::from_disk(&config_path)?;
|
||||||
|
} else {
|
||||||
|
self.config = Config::default();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
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();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue