fixed cargo create bug

This commit is contained in:
mgbvox 2023-01-19 11:35:25 -05:00
parent eb91d779cf
commit e38092fc44
4 changed files with 5 additions and 15 deletions

View file

@ -17,7 +17,7 @@ pub struct Create {
impl Create {
pub fn create(self) -> Result<()> {
if Self::name_valid_check(self.name.clone()) {
return custom_error!("❗Unsupported project name.");
return custom_error!("❗Unsupported project name: '{}'.", &self.name);
}
let project_path = PathBuf::from(&self.name);
@ -26,7 +26,7 @@ impl Create {
return custom_error!("🧨 Folder '{}' is initialized.", &self.name);
}
log::info!("🔧 Start to create a new project '{}'.", self.name);
log::info!("🔧 Start: Creating new project '{}'.", self.name);
let output = Command::new("cargo")
.arg("generate")

View file

@ -18,7 +18,7 @@ fn default_plugin() -> toml::Value {
impl DioxusConfig {
pub fn load() -> crate::error::Result<Option<DioxusConfig>> {
let crate_dir = crate::cargo::crate_root()?;
let Ok(crate_dir) = crate::cargo::crate_root() else { return Ok(None); };
// we support either `Dioxus.toml` or `Cargo.toml`
let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {

View file

@ -10,9 +10,9 @@ async fn main() -> anyhow::Result<()> {
set_up_logging();
let dioxus_config = DioxusConfig::load()
.map_err(|e| anyhow!("Failed to load `dioxus.toml` because: {e}"))?
.map_err(|e| anyhow!("Failed to load `Dioxus.toml` because: {e}"))?
.unwrap_or_else(|| {
log::warn!("Your `dioxus.toml` could not be found. Using the default config. To set up this crate with dioxus, use `dioxus init`.");
log::warn!("You appear to be creating a Dioxus project from scratch; we will use the default config");
DioxusConfig::default()
});

View file

@ -7,14 +7,4 @@ use std::process::Command; // Run programs
#[test]
fn ready() {
println!("Compiled successfully!")
}
#[test]
fn test_create() -> Result<(), Box<dyn Error>> {
let mut cmd = Command::cargo_bin("dioxus")?;
cmd.arg("create").arg("scratch");
cmd.assert()
.failure();
Ok(())
}