fixed cargo create bug
This commit is contained in:
1 parent
eb91d779cf
commit
e38092fc44
4 files changed
+5
-15
No files matched your search
@@ -17,7 +17,7 @@ pub struct Create {
|
|||||||
impl Create {
|
impl Create {
|
||||||
pub fn create(self) -> Result<()> {
|
pub fn create(self) -> Result<()> {
|
||||||
if Self::name_valid_check(self.name.clone()) {
|
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);
|
let project_path = PathBuf::from(&self.name);
|
||||||
@@ -26,7 +26,7 @@ impl Create {
|
|||||||
return custom_error!("🧨 Folder '{}' is initialized.", &self.name);
|
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")
|
let output = Command::new("cargo")
|
||||||
.arg("generate")
|
.arg("generate")
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ fn default_plugin() -> toml::Value {
|
|||||||
|
|
||||||
impl DioxusConfig {
|
impl DioxusConfig {
|
||||||
pub fn load() -> crate::error::Result<Option<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`
|
// we support either `Dioxus.toml` or `Cargo.toml`
|
||||||
let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {
|
let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {
|
||||||
|
|||||||
+2
-2
@@ -10,9 +10,9 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
set_up_logging();
|
set_up_logging();
|
||||||
|
|
||||||
let dioxus_config = DioxusConfig::load()
|
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(|| {
|
.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()
|
DioxusConfig::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,3 @@ use std::process::Command; // Run programs
|
|||||||
fn ready() {
|
fn ready() {
|
||||||
println!("Compiled successfully!")
|
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(())
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user