From d2d0aebecd0df0d66dda29c742b371f932f8274d Mon Sep 17 00:00:00 2001 From: josh rotenberg Date: Tue, 28 Dec 2021 21:00:06 -0800 Subject: [PATCH] check for the index.html file first --- src/cmd/build.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 5fe73236..dacf45cf 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -2,6 +2,7 @@ use crate::{get_book_dir, open}; use clap::{arg, App, Arg, ArgMatches}; use mdbook::errors::Result; use mdbook::MDBook; +use std::path::Path; // Create clap subcommand arguments pub fn make_subcommand<'help>() -> App<'help> { @@ -39,11 +40,12 @@ pub fn execute(args: &ArgMatches) -> Result<()> { if args.is_present("open") { // FIXME: What's the right behaviour if we don't use the HTML renderer? let path = book.build_dir_for("html").join("index.html"); - if !path.exists() { - error!("No chapter available to open"); - std::process::exit(1) + if !Path::new(&path).exists() { + error!("Need a more descriptive error here: {:?}", path); + std::process::exit(1); } - open(path); + + open(book.build_dir_for("html").join("index.html")); } Ok(())