Skip to content

Commit

Permalink
Added canonicalization for load_paths
Browse files Browse the repository at this point in the history
  • Loading branch information
myFavShrimp committed Aug 2, 2023
1 parent 9fd6e0b commit f474322
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/turf_internals/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use std::path::PathBuf;

use serde::Deserialize;

use crate::path::canonicalize;

#[derive(Deserialize, Debug, Default, Clone)]
pub struct Settings {
pub(crate) debug: Option<bool>,
Expand All @@ -15,13 +17,22 @@ impl Settings {
pub fn debug_enabled(&self) -> bool {
self.debug.unwrap_or(false)
}

pub fn canonicalized_load_paths(&self) -> Vec<PathBuf> {
self.load_paths
.clone()
.unwrap_or(Default::default())
.into_iter()
.map(canonicalize)
.collect()
}
}

impl<'a> From<Settings> for grass::Options<'a> {
fn from(val: Settings) -> Self {
grass::Options::default()
.style(grass::OutputStyle::Expanded)
.load_paths(&val.load_paths.unwrap_or(Default::default()))
.load_paths(&val.canonicalized_load_paths())
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/load_settings_from_cargo_manifest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ path = "../../lib/turf"
path = "../../lib/turf_internals"

[package.metadata.turf]
load_paths = ["variables"]
load_paths = ["../variables"]
minify = false

0 comments on commit f474322

Please sign in to comment.