From f15a43b2fca2360e860f69f008fbaff038ba31f0 Mon Sep 17 00:00:00 2001 From: "Azat S." Date: Sun, 3 Nov 2024 20:21:56 +0300 Subject: [PATCH] fix: create directory for json output --- src/project/generate_output.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/project/generate_output.rs b/src/project/generate_output.rs index 330aabf..3c71d17 100644 --- a/src/project/generate_output.rs +++ b/src/project/generate_output.rs @@ -54,7 +54,15 @@ pub async fn generate_output( } } OutputFormat::Json => { - let json_path = Path::new(output_directory).join("report.json"); + if let Err(e) = fs::create_dir_all(output_directory).await { + eprintln!( + "Error creating output directory {}: {:?}", + output_directory, e + ); + return; + } + + let json_path = Path::new(output_directory).join("index.json"); let mut file = File::create(&json_path) .expect("Failed to create JSON report file"); let formatted_json = serde_json::to_string_pretty(&json_data)