Skip to content

Commit

Permalink
Export get_scheme_files to allow users to get &[SchemeFile] from dir
Browse files Browse the repository at this point in the history
  • Loading branch information
JamyGolden committed Oct 5, 2024
1 parent 821b1a8 commit 7d3a617
Show file tree
Hide file tree
Showing 11 changed files with 597 additions and 421 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- BREAKING: Remove `tinted_builder` exports since they should be
imported from `tinted_builder` crate itself
- Export `get_scheme_files` to allow Rust users to get a
`&'static [SchemeFile]` from a directory

## [0.11.1] - 2024-10-02

Expand Down
19 changes: 19 additions & 0 deletions tinted-builder-rust/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use anyhow::{Context, Result};
use std::fs::{remove_file, File};
use std::io::Write;
use std::path::Path;

#[allow(dead_code)]
pub(crate) fn write_to_file(path: impl AsRef<Path>, contents: &str) -> Result<()> {
if path.as_ref().exists() {
remove_file(path.as_ref())
.with_context(|| format!("Unable to remove file: {}", path.as_ref().display()))?;
}

let mut file = File::create(path.as_ref())
.with_context(|| format!("Unable to create file: {}", path.as_ref().display()))?;

file.write_all(contents.as_bytes())?;

Ok(())
}
7 changes: 6 additions & 1 deletion tinted-builder-rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
mod operations {
pub mod build;
}
mod utils;

mod helpers;

pub mod utils {
pub use crate::operations::build::utils::get_scheme_files;
}

pub use crate::operations::build as operation_build;
2 changes: 1 addition & 1 deletion tinted-builder-rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod operations {
pub(crate) mod build;
pub(crate) mod sync;
}
mod utils;
mod helpers;

use anyhow::{anyhow, Result};
use std::path::PathBuf;
Expand Down
Loading

0 comments on commit 7d3a617

Please sign in to comment.