diff --git a/src/bin/build.rs b/src/bin/build.rs index 6e311e51..123fccc1 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -17,7 +17,7 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> { // Build command implementation pub fn execute(args: &ArgMatches) -> Result<()> { let book_dir = get_book_dir(args); - let book = MDBook::new(&book_dir).read_config()?; + let book = MDBook::new(&book_dir); let mut book = match args.value_of("dest-dir") { Some(dest_dir) => book.with_destination(dest_dir), @@ -30,6 +30,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> { book = book.with_curly_quotes(true); } + book = book.read_config()?; book.build()?; if args.is_present("open") { diff --git a/src/book/mod.rs b/src/book/mod.rs index 8e666a4b..77bd6ed1 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -83,7 +83,7 @@ impl MDBook { renderer: Box::new(HtmlHandlebars::new()), livereload: None, - create_missing: true, + create_missing: false, } } @@ -175,15 +175,18 @@ impl MDBook { let src = self.config.get_source(); let summary = src.join("SUMMARY.md"); - if summary.exists() && self.create_missing { + if summary.exists() { + if self.create_missing { // As a special case, if we run "mdbook init" on a book which // already has a summary we'll read that summary and create // stubs for any files which don't already exist (@azerupi likes // having access to this shortcut). return create_files_from_summary(&src, &summary); + } else { + return Ok(()); + } } - // We need to create the summary file debug!("[*]: Creating SUMMARY.md"); let mut f = File::create(&summary)?; writeln!(f, "{}", STUB_SUMMARY_CONTENTS)?;