From ec46835564b8d366628493f18c9758c7c29d931f Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Wed, 12 Feb 2025 12:34:59 +0000 Subject: [PATCH] Fix: Don't use temp folder name in output folder path Fixes #374. --- src/commands.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index a1e40963..fc617827 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -72,6 +72,8 @@ pub fn handle_example_run_command(name: &str) -> Result<()> { // Creates temporary directory let temp_dir = TempDir::new().context("Failed to create temporary directory.")?; + let temp_path = temp_dir.path().join(name); + fs::create_dir(&temp_path)?; // Copies the contents of the subdirectory to the temporary directory for entry in sub_dir.entries() { @@ -79,13 +81,13 @@ pub fn handle_example_run_command(name: &str) -> Result<()> { DirEntry::Dir(_) => panic!("Subdirectories in examples not supported"), DirEntry::File(f) => { let file_name = f.path().file_name().unwrap(); - let file_path = temp_dir.path().join(file_name); + let file_path = temp_path.join(file_name); fs::write(&file_path, f.contents())?; } } } - handle_run_command(temp_dir.path()) + handle_run_command(&temp_path) } /// Handle the `example list` command.