SCSS relative path support, set cwd of server to eww config directory (#110)
This commit is contained in:
parent
d2fa79f050
commit
4da676e38b
3 changed files with 8 additions and 4 deletions
|
@ -90,6 +90,7 @@ fn main() {
|
|||
} else {
|
||||
log::info!("Initializing Eww server.");
|
||||
let _ = std::fs::remove_file(&*crate::IPC_SOCKET_PATH);
|
||||
|
||||
println!("Run `eww logs` to see any errors, warnings or information while editing your configuration.");
|
||||
server::initialize_server(config)?;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ pub fn initialize_server(config_dir_override: Option<std::path::PathBuf>) -> Res
|
|||
.parent()
|
||||
.context("config file did not have a parent?!")?
|
||||
.to_owned();
|
||||
std::env::set_current_dir(&config_dir).with_context(|| { format!("Failed to change working directory to {}", config_dir.display()) } )?;
|
||||
let scss_file_path = config_dir.join("eww.scss");
|
||||
|
||||
log::info!("reading configuration from {:?}", &config_file_path);
|
||||
|
|
10
src/util.rs
10
src/util.rs
|
@ -52,10 +52,12 @@ macro_rules! loop_select {
|
|||
|
||||
/// read an scss file, replace all environment variable references within it and
|
||||
/// then parse it into css.
|
||||
pub fn parse_scss_from_file<P: AsRef<Path>>(path: P) -> Result<String> {
|
||||
let scss_content = replace_env_var_references(std::fs::read_to_string(path)?);
|
||||
grass::from_string(scss_content, &grass::Options::default())
|
||||
.map_err(|err| anyhow!("encountered SCSS parsing error: {:?}", err))
|
||||
pub fn parse_scss_from_file(path: &Path) -> Result<String> {
|
||||
let config_dir = path.parent().context("Given SCSS file has no parent directory?!")?;
|
||||
let scss_file_content = std::fs::read_to_string(path).with_context(|| { format!("Given SCSS File Doesnt Exist! {}", path.display()) })?;
|
||||
let file_content = replace_env_var_references(scss_file_content);
|
||||
let grass_config = grass::Options::default().load_path(config_dir);
|
||||
grass::from_string(file_content, &grass_config).map_err(|err| anyhow!("Encountered SCSS parsing error: {:?}", err))
|
||||
}
|
||||
|
||||
#[ext(pub, name = StringExt)]
|
||||
|
|
Loading…
Add table
Reference in a new issue