From 502e26b469845ef021f0162e92c1cdd9baef5bdc Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 4 Apr 2024 10:07:24 -0500 Subject: [PATCH] fix(trycmd): Ensure overwrite happens This is a partial revert of db1dcb0. More examination will be needed to get that to work. Fixes #269 --- src/schema.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/schema.rs b/src/schema.rs index e2886313..35afed44 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -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))?; @@ -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)