fmt: fmt
This commit is contained in:
parent
e4bff03f91
commit
26d32be1be
5 changed files with 36 additions and 22 deletions
|
|
@ -185,10 +185,9 @@ impl SabryBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
let css = self.css_compiler.compile_module(
|
||||
scope.original_scope.adapter().syntax,
|
||||
&scope.hashed_code,
|
||||
)?;
|
||||
let css = self
|
||||
.css_compiler
|
||||
.compile_module(scope.original_scope.adapter().syntax, &scope.hashed_code)?;
|
||||
self.state
|
||||
.loaded_css_modules
|
||||
.push((scope.original_scope.name.to_string(), css));
|
||||
|
|
@ -196,7 +195,9 @@ impl SabryBuilder {
|
|||
|
||||
// compile sass preludes into the CSS prelude
|
||||
for pre in &self.state.sass_prelude {
|
||||
let css = self.css_compiler.compile_module(pre.syntax.into(), &pre.code)?;
|
||||
let css = self
|
||||
.css_compiler
|
||||
.compile_module(pre.syntax.into(), &pre.code)?;
|
||||
self.state.css_prelude.push_str(&css);
|
||||
}
|
||||
|
||||
|
|
@ -263,10 +264,18 @@ impl SabryBuilder {
|
|||
for pre in sass_pres {
|
||||
let pre_path = PathBuf::from_str(pre)?;
|
||||
|
||||
let syntax = pre_path.extension().unwrap_or_default().to_str().unwrap_or_default();
|
||||
let syntax = pre_path
|
||||
.extension()
|
||||
.unwrap_or_default()
|
||||
.to_str()
|
||||
.unwrap_or_default();
|
||||
let syntax = match ArbitraryStyleSyntax::try_from(syntax) {
|
||||
Ok(s) => s,
|
||||
Err(_) => return Err(SabryBuildError::Another(format!("Unknown syntax for sass prelude {pre}")))
|
||||
Err(_) => {
|
||||
return Err(SabryBuildError::Another(format!(
|
||||
"Unknown syntax for sass prelude {pre}"
|
||||
)))
|
||||
}
|
||||
};
|
||||
|
||||
let code = fs::read_to_string(pre_path)?;
|
||||
|
|
@ -349,7 +358,7 @@ pub struct SabryBuildState {
|
|||
css_prelude: String,
|
||||
/// SASS preludes loaded from config
|
||||
/// Should be compiled into loaded_css_modules as well
|
||||
sass_prelude: Vec<SassPreludeModule>
|
||||
sass_prelude: Vec<SassPreludeModule>,
|
||||
}
|
||||
|
||||
/// Convenience struct for [SabryBuildState::sass_prelude]
|
||||
|
|
@ -357,7 +366,7 @@ pub struct SassPreludeModule {
|
|||
/// syntax for the prelude
|
||||
syntax: ArbitraryStyleSyntax,
|
||||
/// code of the prelude
|
||||
code: String
|
||||
code: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
|
@ -387,5 +396,5 @@ pub enum SabryBuildError {
|
|||
#[error("Failed to load config/manifest")]
|
||||
Manifest(#[from] ManifestError),
|
||||
#[error("Another error")]
|
||||
Another(String)
|
||||
Another(String),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,9 @@ impl ScopeHash {
|
|||
mod test {
|
||||
use syn::Ident;
|
||||
|
||||
use crate::{config::SabryHashConfig, scoper::ArbitraryScope, syntax::ostrta::OneSyntaxToRuleThemAll};
|
||||
use crate::{
|
||||
config::SabryHashConfig, scoper::ArbitraryScope, syntax::ostrta::OneSyntaxToRuleThemAll,
|
||||
};
|
||||
|
||||
use super::ScopeHash;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ use hash::ScopeHash;
|
|||
use raffia::Spanned;
|
||||
use regex::Regex;
|
||||
|
||||
use crate::{config::SabryHashConfig, syntax::{ostrta::OneSyntaxToRuleThemAll, StylesheetAdapter}};
|
||||
use crate::{
|
||||
config::SabryHashConfig,
|
||||
syntax::{ostrta::OneSyntaxToRuleThemAll, StylesheetAdapter},
|
||||
};
|
||||
|
||||
pub mod hash;
|
||||
|
||||
|
|
@ -375,7 +378,8 @@ mod test {
|
|||
|
||||
use crate::{
|
||||
config::SabryHashConfig,
|
||||
scoper::{hash::ScopeHash, HashedScope}, syntax::ostrta::OneSyntaxToRuleThemAll,
|
||||
scoper::{hash::ScopeHash, HashedScope},
|
||||
syntax::ostrta::OneSyntaxToRuleThemAll,
|
||||
};
|
||||
|
||||
use super::ArbitraryScope;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum OneSyntaxToRuleThemAll {
|
||||
Sass,
|
||||
Scss
|
||||
Scss,
|
||||
}
|
||||
|
||||
impl Default for OneSyntaxToRuleThemAll {
|
||||
|
|
@ -18,7 +18,7 @@ impl TryFrom<&str> for OneSyntaxToRuleThemAll {
|
|||
match value {
|
||||
"sass" => Ok(Self::Sass),
|
||||
"scss" => Ok(Self::Scss),
|
||||
_ => Err(())
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ impl TryFrom<raffia::Syntax> for OneSyntaxToRuleThemAll {
|
|||
match value {
|
||||
raffia::Syntax::Sass => Ok(Self::Sass),
|
||||
raffia::Syntax::Scss => Ok(Self::Scss),
|
||||
_ => Err(())
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ impl TryFrom<grass::InputSyntax> for OneSyntaxToRuleThemAll {
|
|||
match value {
|
||||
grass::InputSyntax::Sass => Ok(Self::Sass),
|
||||
grass::InputSyntax::Scss => Ok(Self::Scss),
|
||||
_ => Err(())
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ impl From<OneSyntaxToRuleThemAll> for raffia::Syntax {
|
|||
fn from(value: OneSyntaxToRuleThemAll) -> Self {
|
||||
match value {
|
||||
OneSyntaxToRuleThemAll::Sass => Self::Sass,
|
||||
OneSyntaxToRuleThemAll::Scss => Self::Scss
|
||||
OneSyntaxToRuleThemAll::Scss => Self::Scss,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ impl From<OneSyntaxToRuleThemAll> for grass::InputSyntax {
|
|||
fn from(value: OneSyntaxToRuleThemAll) -> Self {
|
||||
match value {
|
||||
OneSyntaxToRuleThemAll::Scss => Self::Scss,
|
||||
OneSyntaxToRuleThemAll::Sass => Self::Sass
|
||||
OneSyntaxToRuleThemAll::Sass => Self::Sass,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ pub fn styly_macro_impl(input: TokenStream) -> TokenStream {
|
|||
Err(e) => return e.to_compile_error(),
|
||||
};
|
||||
|
||||
let scope = match ArbitraryScope::from_source(ms.syntax.0, ms.scope.clone(), &ms.code.code)
|
||||
{
|
||||
let scope = match ArbitraryScope::from_source(ms.syntax.0, ms.scope.clone(), &ms.code.code) {
|
||||
Ok(s) => match s.hashed(&config.hash) {
|
||||
Ok(hs) => Ok(hs),
|
||||
Err(e) => Err(e),
|
||||
|
|
|
|||
Loading…
Reference in a new issue