Skip to content

Commit

Permalink
🐛 Fix --force flag handling
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielePicco committed Jan 27, 2024
1 parent 17e1374 commit 1b224b9
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,26 +236,23 @@ fn init(
fs::write(".gitignore", rust_template::git_ignore())?;

// Initialize .prettierignore file
fs::write(
".prettierignore",
rust_template::prettier_ignore(),
)?;
fs::write(".prettierignore", rust_template::prettier_ignore())?;

// Remove the default programs if `--force` is passed
if force {
fs::remove_dir_all(
std::env::current_dir()?
.join(if solidity { "solidity" } else { "programs" })
.join(&project_name),
)?;
fs::remove_dir_all(
std::env::current_dir()?
.join("programs-ecs")
.join(&project_name),
)?;
let programs_path = std::env::current_dir()?
.join(if solidity { "solidity" } else { "programs" })
.join(&project_name);
fs::create_dir_all(&programs_path)?;
fs::remove_dir_all(&programs_path)?;
let programs_ecs_path = std::env::current_dir()?
.join("programs-ecs")
.join(&project_name);
fs::create_dir_all(&programs_ecs_path)?;
fs::remove_dir_all(&programs_ecs_path)?;
}

//Build the program.
// Build the program.
if solidity {
anchor_cli::solidity_template::create_program(&project_name)?;
} else {
Expand Down

0 comments on commit 1b224b9

Please sign in to comment.