浏览代码

fix(cli): pass `--no-default-features` to runner instead of app, closes #5415 (#5474)

Amr Bashir 2 年之前
父节点
当前提交
a3a70218f3
共有 2 个文件被更改,包括 20 次插入14 次删除
  1. 5 0
      .changes/cli-no-default-featurs-arg.md
  2. 15 14
      tooling/cli/src/interface/rust.rs

+ 5 - 0
.changes/cli-no-default-featurs-arg.md

@@ -0,0 +1,5 @@
+---
+"cli.rs": "patch"
+---
+
+Fix cli passing `--no-default-features` to the app instead of the runner (Cargo).

+ 15 - 14
tooling/cli/src/interface/rust.rs

@@ -285,7 +285,20 @@ impl Rust {
     mut options: Options,
     on_exit: F,
   ) -> crate::Result<DevChild> {
-    if !options.args.contains(&"--no-default-features".into()) {
+    let mut args = Vec::new();
+    let mut run_args = Vec::new();
+    let mut reached_run_args = false;
+    for arg in options.args.clone() {
+      if reached_run_args {
+        run_args.push(arg);
+      } else if arg == "--" {
+        reached_run_args = true;
+      } else {
+        args.push(arg);
+      }
+    }
+
+    if !args.contains(&"--no-default-features".into()) {
       let manifest_features = self.app_settings.manifest.features();
       let enable_features: Vec<String> = manifest_features
         .get("default")
@@ -300,7 +313,7 @@ impl Rust {
           }
         })
         .collect();
-      options.args.push("--no-default-features".into());
+      args.push("--no-default-features".into());
       if !enable_features.is_empty() {
         options
           .features
@@ -309,18 +322,6 @@ impl Rust {
       }
     }
 
-    let mut args = Vec::new();
-    let mut run_args = Vec::new();
-    let mut reached_run_args = false;
-    for arg in options.args.clone() {
-      if reached_run_args {
-        run_args.push(arg);
-      } else if arg == "--" {
-        reached_run_args = true;
-      } else {
-        args.push(arg);
-      }
-    }
     options.args = args;
 
     desktop::run_dev(