CR review: s/Options/SassOptions/, break bail args in compile_sass into multiple lines

This commit is contained in:
Erich Gubler 2018-03-19 10:04:48 -06:00
parent ea4cc63aa9
commit 0d8dc656f1
1 changed files with 9 additions and 4 deletions

View File

@ -28,7 +28,7 @@ use std::path::{Path, PathBuf};
use glob::glob; use glob::glob;
use tera::{Tera, Context}; use tera::{Tera, Context};
use walkdir::WalkDir; use walkdir::WalkDir;
use sass_rs::{Options, OutputStyle, compile_file}; use sass_rs::{Options as SassOptions, OutputStyle, compile_file};
use errors::{Result, ResultExt}; use errors::{Result, ResultExt};
use config::{Config, get_config}; use config::{Config, get_config};
@ -537,7 +537,7 @@ impl Site {
sass_path sass_path
}; };
let mut options = Options::default(); let mut options = SassOptions::default();
options.output_style = OutputStyle::Compressed; options.output_style = OutputStyle::Compressed;
let mut compiled_paths = self.compile_sass_glob(&sass_path, "scss", options.clone())?; let mut compiled_paths = self.compile_sass_glob(&sass_path, "scss", options.clone())?;
@ -547,14 +547,19 @@ impl Site {
compiled_paths.sort(); compiled_paths.sort();
for window in compiled_paths.windows(2) { for window in compiled_paths.windows(2) {
if window[0].1 == window[1].1 { if window[0].1 == window[1].1 {
bail!("SASS path conflict: \"{}\" and \"{}\" both compile to \"{}\"", window[0].0.display(), window[1].0.display(), window[0].1.display()); bail!(
"SASS path conflict: \"{}\" and \"{}\" both compile to \"{}\"",
window[0].0.display(),
window[1].0.display(),
window[0].1.display(),
);
} }
} }
Ok(()) Ok(())
} }
fn compile_sass_glob(&self, sass_path: &Path, extension: &str, options: Options) -> Result<Vec<(PathBuf, PathBuf)>> { fn compile_sass_glob(&self, sass_path: &Path, extension: &str, options: SassOptions) -> Result<Vec<(PathBuf, PathBuf)>> {
let glob_string = format!("{}/**/*.{}", sass_path.display(), extension); let glob_string = format!("{}/**/*.{}", sass_path.display(), extension);
let files = glob(&glob_string) let files = glob(&glob_string)
.unwrap() .unwrap()