2020-02-10 19:48:52 +00:00
|
|
|
use std::path::{Path, PathBuf};
|
2019-05-27 12:05:07 +00:00
|
|
|
|
|
|
|
use errors::Result;
|
|
|
|
use site::Site;
|
|
|
|
|
2019-12-21 21:52:39 +00:00
|
|
|
use crate::console;
|
2019-05-27 12:05:07 +00:00
|
|
|
|
2019-08-24 20:23:08 +00:00
|
|
|
pub fn check(
|
2020-01-21 19:52:24 +00:00
|
|
|
root_dir: &Path,
|
2020-05-23 09:55:45 +00:00
|
|
|
config_file: &Path,
|
2019-08-24 20:23:08 +00:00
|
|
|
base_path: Option<&str>,
|
|
|
|
base_url: Option<&str>,
|
|
|
|
include_drafts: bool,
|
|
|
|
) -> Result<()> {
|
2020-01-21 19:52:24 +00:00
|
|
|
let bp = base_path.map(PathBuf::from).unwrap_or_else(|| PathBuf::from(root_dir));
|
2019-05-27 12:05:07 +00:00
|
|
|
let mut site = Site::new(bp, config_file)?;
|
|
|
|
// Force the checking of external links
|
2019-07-12 21:09:05 +00:00
|
|
|
site.config.enable_check_mode();
|
2019-05-27 12:05:07 +00:00
|
|
|
if let Some(b) = base_url {
|
|
|
|
site.set_base_url(b.to_string());
|
|
|
|
}
|
2019-08-24 20:23:08 +00:00
|
|
|
if include_drafts {
|
|
|
|
site.include_drafts();
|
|
|
|
}
|
2019-05-27 12:05:07 +00:00
|
|
|
site.load()?;
|
2019-07-12 21:43:07 +00:00
|
|
|
console::check_site_summary(&site);
|
2019-05-27 12:05:07 +00:00
|
|
|
console::warn_about_ignored_pages(&site);
|
|
|
|
Ok(())
|
|
|
|
}
|