Skip to content

Commit

Permalink
Rename Cargo.toml in the init template files (#1206)
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman authored Feb 21, 2024
1 parent 4febbe2 commit 53ee2e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/soroban-cli/src/commands/contract/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ fn init(

fn copy_template_files(project_path: &Path) -> Result<(), Error> {
for item in TemplateFiles::iter() {
let to = project_path.join(item.as_ref());
let mut to = project_path.join(item.as_ref());

if file_exists(&to.to_string_lossy()) {
println!(
"ℹ️ Skipped creating {} as it already exists",
Expand All @@ -224,6 +225,11 @@ fn copy_template_files(project_path: &Path) -> Result<(), Error> {
e
})?;

// We need to include the Cargo.toml file as Cargo.text in the template so that it will be included the package. This is making sure that the Cargo file is written as Cargo.toml in the new project. This is a workaround for this issue: https://github.com/rust-lang/cargo/issues/8597.
if item == "Cargo.toml.removeextension" {
to = project_path.join("Cargo.toml");
}

println!("➕ Writing {}", &to.to_string_lossy());
write(&to, file_contents).map_err(|e| {
eprintln!("Error writing file: {to:?}");
Expand Down

0 comments on commit 53ee2e6

Please sign in to comment.