Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added error msg to forc-init when proj-name is test #1144

Merged
merged 4 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions forc-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
}
Expand Down
2 changes: 2 additions & 0 deletions forc/src/ops/forc_init.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) => {
Expand Down