Skip to content

Commit

Permalink
fix: only set cwd for editor command
Browse files Browse the repository at this point in the history
fixes relative tmp directories not being deleted
  • Loading branch information
marcelohdez committed Feb 15, 2024
1 parent de0233a commit 5697097
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ pub fn try_template(
.join(format!("{template}_{time}"));
copy_dir_recursively(wanted_dir, &tmp_dir)?;

std::env::set_current_dir(&tmp_dir).expect("Could not change to temp directory!");
Command::new(editor)
.arg(&tmp_dir)
.spawn()?
.current_dir(&tmp_dir)
.arg(".")
.spawn()
.context("Failed to launch editor!")?
.wait()
.expect("Could not launch editor!");
.context("Failed waiting for editor!")?;

if delete || ask_y_n("Would you like to keep this project?")? {
println!("Saved as {tmp_dir:?}.");
Expand Down
2 changes: 1 addition & 1 deletion src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl TryFrom<&Path> for Templates {

let mut templates = Vec::new();
for entry in entries {
let path = entry?.path();
let path = entry.context("Failed to unwrap templates entry!")?.path();

if path.is_dir() {
templates.push(path);
Expand Down

0 comments on commit 5697097

Please sign in to comment.