Skip to content

Commit

Permalink
fix: No such file or directory on write (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-martinez authored Sep 14, 2024
1 parent d6e14cc commit d9578d6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/projectmanager/nvim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub fn add_project(
// Write the updated JSON data back to the file
let updated_data =
serde_json::to_string_pretty(&entries).expect("Failed to serialize JSON");
let _ = fs::create_dir_all(&target_path.parent().unwrap());
fs::write(&target_path, updated_data).expect("Unable to write file");
if debug {
println!("Entry added {:#?}", new_entry);
Expand Down
1 change: 1 addition & 0 deletions src/projectmanager/vscode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub fn add_project(
// Write the updated JSON data back to the file
let updated_data =
serde_json::to_string_pretty(&entries).expect("Failed to serialize JSON");
let _ = fs::create_dir_all(&target_path.parent().unwrap());
fs::write(&target_path, updated_data).expect("Unable to write file");
if debug {
println!("Entry added {:#?}", new_entry);
Expand Down

0 comments on commit d9578d6

Please sign in to comment.