Skip to content

Commit

Permalink
Merge pull request #270 from epage/overwrite
Browse files Browse the repository at this point in the history
fix(trycmd): Ensure overwrite happens
  • Loading branch information
epage authored Apr 4, 2024
2 parents 28de73b + 502e26b commit a9d81dc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,9 @@ fn overwrite_toml_output(
output_field: &str,
) -> Result<(), crate::Error> {
if let Some(output) = output {
if let Some(source) = output.source() {
output.write_to(source)?;
let output_path = path.with_extension(output_ext);
if output_path.exists() {
output.write_to_path(&output_path)?;
} else if let Some(output) = output.render() {
let raw = std::fs::read_to_string(path)
.map_err(|e| format!("Failed to read {}: {}", path.display(), e))?;
Expand All @@ -355,7 +356,6 @@ fn overwrite_toml_output(
std::fs::write(path, doc.to_string())
.map_err(|e| format!("Failed to write {}: {}", path.display(), e))?;
} else {
let output_path = path.with_extension(output_ext);
output.write_to_path(&output_path)?;

let raw = std::fs::read_to_string(path)
Expand Down

0 comments on commit a9d81dc

Please sign in to comment.