Skip to content

Commit

Permalink
Merge pull request #394 from EnergySystemsModellingLab/fix-example-ou…
Browse files Browse the repository at this point in the history
…tput-folder-name

Fix: Don't use temp folder name in output folder path
  • Loading branch information
alexdewar authored Feb 26, 2025
2 parents 7733c8d + ec46835 commit a3f60ab
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,22 @@ 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() {
match entry {
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.
Expand Down

0 comments on commit a3f60ab

Please sign in to comment.