From 9a5134b4e3a3d4857638a026e72ea88418350b62 Mon Sep 17 00:00:00 2001 From: Rasmus Kaj Date: Thu, 25 Aug 2022 19:50:53 +0200 Subject: [PATCH] Prepare for rsass 0.26. MRSV is now 1.56.1. --- .github/workflows/ci.yml | 5 ++--- Cargo.toml | 2 +- src/lib.rs | 12 ++++++------ src/staticfiles.rs | 19 +++++++++---------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b435e8..5d4c953 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,9 +12,8 @@ jobs: matrix: rust: - stable - - 1.52.1 - - 1.48.0 - - 1.46.0 + - 1.60.0 + - 1.56.1 - beta - nightly steps: diff --git a/Cargo.toml b/Cargo.toml index a5d3e05..540303c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ itertools = "0.10.0" md5 = "0.7" nom = "7.1.0" -rsass = { version = "0.25.0", optional = true } +rsass = { git = "https://github.com/kaj/rsass", optional = true } mime = { version = "0.3", optional = true } [badges] diff --git a/src/lib.rs b/src/lib.rs index a8338ff..aae1c40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -455,20 +455,20 @@ impl Error for RucteError { } impl Display for RucteError { + fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result { + write!(out, "Error: {:?}", self) + } +} +impl Debug for RucteError { fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result { match self { RucteError::Io(err) => Display::fmt(err, out), RucteError::Env(var, err) => write!(out, "{:?}: {}", var, err), #[cfg(feature = "sass")] - RucteError::Sass(err) => Display::fmt(err, out), + RucteError::Sass(err) => Debug::fmt(err, out), } } } -impl Debug for RucteError { - fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(self, out) - } -} impl From for RucteError { fn from(e: io::Error) -> RucteError { diff --git a/src/staticfiles.rs b/src/staticfiles.rs index a25cd7b..85ce359 100644 --- a/src/staticfiles.rs +++ b/src/staticfiles.rs @@ -469,8 +469,9 @@ impl StaticFile { { let src = self.path_for(src); use rsass::css::CssString; + use rsass::input::CargoContext; use rsass::output::{Format, Style}; - use rsass::sass::FormalArgs; + use rsass::sass::{CallError, FormalArgs}; use rsass::value::Quotes; use rsass::*; use std::sync::Arc; @@ -478,13 +479,12 @@ impl StaticFile { style: Style::Compressed, precision: 4, }; - let scope = ScopeRef::new_global(format); - - // TODO Find any referenced files! - println!("cargo:rerun-if-changed={}", src.display()); + let (context, scss) = + CargoContext::for_path(&src).map_err(rsass::Error::from)?; + let mut context = context.with_format(format); let existing_statics = Arc::new(self.get_names().clone()); - scope.define_function( + context.get_scope().define_function( "static_name".into(), sass::Function::builtin( "", @@ -503,12 +503,12 @@ impl StaticFile { .into()); } } - Err(Error::S(format!( + Err(CallError::msg(format!( "Static file {} not found", name, ))) } - name => Err(Error::BadArgument( + name => Err(CallError::BadArgument( "name".into(), format!( "{} is not a string", @@ -519,8 +519,7 @@ impl StaticFile { ), ); - let (file_context, scss) = FsFileContext::for_path(&src)?; - let css = format.write_root(scss.parse()?, scope, &file_context)?; + let css = context.transform(scss)?; self.add_file_data(&src.with_extension("css"), &css) }