From af8ab40fee4597c64b6d40bb67b597b7923347e3 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 15 Mar 2022 08:21:03 -0400 Subject: [PATCH] fix: mk out dir if not already exists --- src/bin/compress.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bin/compress.rs b/src/bin/compress.rs index 0a60054d..8d68fc48 100644 --- a/src/bin/compress.rs +++ b/src/bin/compress.rs @@ -102,6 +102,12 @@ fn main() { "invs": step_results.iter().map(|inv| inv.json()).collect::>(), }); - std::fs::write(&args.out, serde_json::to_string_pretty(&out).unwrap()).unwrap(); - println!("Wrote to {:?}",args.out); + let out_path = &args.out; + if let Some(out_path_dir) = out_path.parent() { + if !out_path_dir.exists() { + std::fs::create_dir_all(out_path_dir).unwrap(); + } + } + std::fs::write(out_path, serde_json::to_string_pretty(&out).unwrap()).unwrap(); + println!("Wrote to {:?}", out_path); } \ No newline at end of file