diff --git a/forc-util/src/lib.rs b/forc-util/src/lib.rs index ac005dfb05d..38976965e10 100644 --- a/forc-util/src/lib.rs +++ b/forc-util/src/lib.rs @@ -78,9 +78,9 @@ pub fn validate_name(name: &str, use_case: &str) -> Result<()> { it conflicts with Forc's build directory names" ); } - if name == "test" { + if name.to_lowercase() == "test" { bail!( - "the name `test` cannot be used as a package name, \ + "the name `test` cannot be used as a project name, \ it conflicts with Sway's built-in test library" ); } diff --git a/forc/src/ops/forc_init.rs b/forc/src/ops/forc_init.rs index 70acdaa104d..af3440b49e0 100644 --- a/forc/src/ops/forc_init.rs +++ b/forc/src/ops/forc_init.rs @@ -1,6 +1,7 @@ use crate::cli::InitCommand; use crate::utils::defaults; use anyhow::{anyhow, Context, Result}; +use forc_util::validate_name; use serde::Deserialize; use std::fs; use std::fs::File; @@ -49,6 +50,7 @@ struct ContentResponse { pub fn init(command: InitCommand) -> Result<()> { let project_name = command.project_name; + validate_name(&project_name, "project name")?; match command.template { Some(template) => {