Skip to content

Commit

Permalink
Change hyphens to underscores for library names when running `forc ne…
Browse files Browse the repository at this point in the history
…w/init` (FuelLabs#4048)
  • Loading branch information
mohammadfawaz authored Feb 12, 2023
1 parent dda0f8b commit dfdadf8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions forc/src/ops/forc_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ pub fn init(command: InitCommand) -> Result<()> {
)?,
InitType::Package(ProgramType::Library) => fs::write(
Path::new(&project_dir).join(constants::MANIFEST_FILE_NAME),
defaults::default_pkg_manifest(&project_name, constants::LIB_ENTRY),
// Library names cannot have `-` in them because the Sway compiler does not allow that.
// Even though this is technically not a problem in the toml file, we replace `-` with
// `_` here as well so that the library name in the Sway file matches the one in
// `Forc.toml`
defaults::default_pkg_manifest(&project_name.replace('-', "_"), constants::LIB_ENTRY),
)?,
_ => fs::write(
Path::new(&project_dir).join(constants::MANIFEST_FILE_NAME),
Expand All @@ -134,7 +138,8 @@ pub fn init(command: InitCommand) -> Result<()> {
Path::new(&project_dir)
.join("src")
.join(constants::LIB_ENTRY),
defaults::default_library(&project_name),
// Library names cannot have `-` in them because the Sway compiler does not allow that
defaults::default_library(&project_name.replace('-', "_")),
)?,
InitType::Package(ProgramType::Predicate) => fs::write(
Path::new(&project_dir)
Expand Down

0 comments on commit dfdadf8

Please sign in to comment.