-
Notifications
You must be signed in to change notification settings - Fork 978
/
build.rs
37 lines (33 loc) · 906 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::path::Path;
use errors::{Error, Result};
use site::Site;
use crate::messages;
pub fn build(
root_dir: &Path,
config_file: &Path,
base_url: Option<&str>,
output_dir: Option<&Path>,
force: bool,
include_drafts: bool,
) -> Result<()> {
let mut site = Site::new(root_dir, config_file)?;
if let Some(output_dir) = output_dir {
if !force && output_dir.exists() {
return Err(Error::msg(format!(
"Directory '{}' already exists. Use --force to overwrite.",
output_dir.display(),
)));
}
site.set_output_path(output_dir);
}
if let Some(b) = base_url {
site.set_base_url(b.to_string());
}
if include_drafts {
site.include_drafts();
}
site.load()?;
messages::notify_site_size(&site);
messages::warn_about_ignored_pages(&site);
site.build()
}