Merge pull request #1228 from ehuss/fix-dest-dir
Fix dest-dir command-line flag.
This commit is contained in:
commit
c1ed6ee108
|
@ -63,15 +63,17 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
|
||||||
let address = format!("{}:{}", hostname, port);
|
let address = format!("{}:{}", hostname, port);
|
||||||
|
|
||||||
let livereload_url = format!("ws://{}/{}", address, LIVE_RELOAD_ENDPOINT);
|
let livereload_url = format!("ws://{}/{}", address, LIVE_RELOAD_ENDPOINT);
|
||||||
book.config
|
let update_config = |book: &mut MDBook| {
|
||||||
.set("output.html.livereload-url", &livereload_url)?;
|
book.config
|
||||||
|
.set("output.html.livereload-url", &livereload_url)
|
||||||
if let Some(dest_dir) = args.value_of("dest-dir") {
|
.expect("livereload-url update failed");
|
||||||
book.config.build.build_dir = dest_dir.into();
|
if let Some(dest_dir) = args.value_of("dest-dir") {
|
||||||
}
|
book.config.build.build_dir = dest_dir.into();
|
||||||
// Override site-url for local serving of the 404 file
|
}
|
||||||
book.config.set("output.html.site-url", "/")?;
|
// Override site-url for local serving of the 404 file
|
||||||
|
book.config.set("output.html.site-url", "/").unwrap();
|
||||||
|
};
|
||||||
|
update_config(&mut book);
|
||||||
book.build()?;
|
book.build()?;
|
||||||
|
|
||||||
let sockaddr: SocketAddr = address
|
let sockaddr: SocketAddr = address
|
||||||
|
@ -108,13 +110,10 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
|
||||||
info!("Building book...");
|
info!("Building book...");
|
||||||
|
|
||||||
// FIXME: This area is really ugly because we need to re-set livereload :(
|
// FIXME: This area is really ugly because we need to re-set livereload :(
|
||||||
let result = MDBook::load(&book_dir)
|
let result = MDBook::load(&book_dir).and_then(|mut b| {
|
||||||
.and_then(|mut b| {
|
update_config(&mut b);
|
||||||
b.config
|
b.build()
|
||||||
.set("output.html.livereload-url", &livereload_url)?;
|
});
|
||||||
Ok(b)
|
|
||||||
})
|
|
||||||
.and_then(|b| b.build());
|
|
||||||
|
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
error!("Unable to load the book");
|
error!("Unable to load the book");
|
||||||
|
|
|
@ -28,7 +28,14 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||||
// Watch command implementation
|
// Watch command implementation
|
||||||
pub fn execute(args: &ArgMatches) -> Result<()> {
|
pub fn execute(args: &ArgMatches) -> Result<()> {
|
||||||
let book_dir = get_book_dir(args);
|
let book_dir = get_book_dir(args);
|
||||||
let book = MDBook::load(&book_dir)?;
|
let mut book = MDBook::load(&book_dir)?;
|
||||||
|
|
||||||
|
let update_config = |book: &mut MDBook| {
|
||||||
|
if let Some(dest_dir) = args.value_of("dest-dir") {
|
||||||
|
book.config.build.build_dir = dest_dir.into();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
update_config(&mut book);
|
||||||
|
|
||||||
if args.is_present("open") {
|
if args.is_present("open") {
|
||||||
book.build()?;
|
book.build()?;
|
||||||
|
@ -37,7 +44,10 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
|
||||||
|
|
||||||
trigger_on_change(&book, |paths, book_dir| {
|
trigger_on_change(&book, |paths, book_dir| {
|
||||||
info!("Files changed: {:?}\nBuilding book...\n", paths);
|
info!("Files changed: {:?}\nBuilding book...\n", paths);
|
||||||
let result = MDBook::load(&book_dir).and_then(|b| b.build());
|
let result = MDBook::load(&book_dir).and_then(|mut b| {
|
||||||
|
update_config(&mut b);
|
||||||
|
b.build()
|
||||||
|
});
|
||||||
|
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
error!("Unable to build the book");
|
error!("Unable to build the book");
|
||||||
|
|
|
@ -151,7 +151,8 @@ impl HtmlHandlebars {
|
||||||
data_404.insert("content".to_owned(), json!(html_content_404));
|
data_404.insert("content".to_owned(), json!(html_content_404));
|
||||||
let rendered = handlebars.render("index", &data_404)?;
|
let rendered = handlebars.render("index", &data_404)?;
|
||||||
|
|
||||||
let rendered = self.post_process(rendered, &html_config.playpen, ctx.config.rust.edition);
|
let rendered =
|
||||||
|
self.post_process(rendered, &html_config.playground, ctx.config.rust.edition);
|
||||||
let output_file = get_404_output_file(&html_config.input_404);
|
let output_file = get_404_output_file(&html_config.input_404);
|
||||||
utils::fs::write_file(&destination, output_file, rendered.as_bytes())?;
|
utils::fs::write_file(&destination, output_file, rendered.as_bytes())?;
|
||||||
debug!("Creating 404.html ✓");
|
debug!("Creating 404.html ✓");
|
||||||
|
|
Loading…
Reference in New Issue