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