From e38092fc4451be54162ec73af5b912522819cbcb Mon Sep 17 00:00:00 2001 From: mgbvox Date: Thu, 19 Jan 2023 11:35:25 -0500 Subject: [PATCH] fixed cargo create bug --- src/cli/create/mod.rs | 4 ++-- src/config.rs | 2 +- src/main.rs | 4 ++-- tests/main.rs | 10 ---------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/cli/create/mod.rs b/src/cli/create/mod.rs index 228b87be9..c448e66d1 100644 --- a/src/cli/create/mod.rs +++ b/src/cli/create/mod.rs @@ -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") diff --git a/src/config.rs b/src/config.rs index 99c487fa2..0d9767b97 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,7 +18,7 @@ fn default_plugin() -> toml::Value { impl DioxusConfig { pub fn load() -> crate::error::Result> { - 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 { diff --git a/src/main.rs b/src/main.rs index 278fd43b6..f3c5c6e48 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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() }); diff --git a/tests/main.rs b/tests/main.rs index 6f3db490a..e0fbacf5c 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -7,14 +7,4 @@ use std::process::Command; // Run programs #[test] fn ready() { println!("Compiled successfully!") -} - -#[test] -fn test_create() -> Result<(), Box> { - let mut cmd = Command::cargo_bin("dioxus")?; - cmd.arg("create").arg("scratch"); - cmd.assert() - .failure(); - - Ok(()) } \ No newline at end of file