1
0
Эх сурвалжийг харах

fix: allow post_create on `dx new` to fail silently

Jonathan Kelley 6 сар өмнө
parent
commit
2c9d8aea56

+ 5 - 2
packages/cli/src/cli/create.rs

@@ -81,7 +81,7 @@ impl Create {
         };
         restore_cursor_on_sigint();
         let path = cargo_generate::generate(args)?;
-        post_create(&path)?;
+        _ = post_create(&path);
         Ok(StructuredOutput::Success)
     }
 }
@@ -183,7 +183,10 @@ pub(crate) fn post_create(path: &Path) -> Result<()> {
     // 3. Format the `Cargo.toml` and `Dioxus.toml` files.
     let toml_paths = [path.join("Cargo.toml"), path.join("Dioxus.toml")];
     for toml_path in &toml_paths {
-        let toml = std::fs::read_to_string(toml_path)?;
+        let Ok(toml) = std::fs::read_to_string(toml_path) else {
+            continue;
+        };
+
         let mut toml = toml.parse::<toml_edit::DocumentMut>().map_err(|e| {
             anyhow::anyhow!(
                 "failed to parse toml at {}: {}",

+ 1 - 1
packages/cli/src/cli/init.rs

@@ -73,7 +73,7 @@ impl Init {
         };
         create::restore_cursor_on_sigint();
         let path = cargo_generate::generate(args)?;
-        create::post_create(&path)?;
+        _ = create::post_create(&path);
         Ok(StructuredOutput::Success)
     }
 }