Bladeren bron

refactor(core)!: include all args in `Env.args_os`, closes #9430 (#9552)

* refactor(core)!: include all args in `Env.args_os`, closes #9430

* skip first arg on restart fn

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Amr Bashir 1 jaar geleden
bovenliggende
commit
e8f6eb59a5
4 gewijzigde bestanden met toevoegingen van 10 en 3 verwijderingen
  1. 6 0
      .changes/core-env-args.md
  2. 1 1
      core/tauri-build/src/manifest.rs
  3. 1 1
      core/tauri-utils/src/lib.rs
  4. 2 1
      core/tauri/src/process.rs

+ 6 - 0
.changes/core-env-args.md

@@ -0,0 +1,6 @@
+---
+"tauri": "patch:breaking"
+---
+
+Include binary path in `Env.args_os`, previously it was skipped.
+

+ 1 - 1
core/tauri-build/src/manifest.rs

@@ -65,7 +65,7 @@ pub fn check(config: &Config, manifest: &mut Manifest) -> Result<()> {
     if deps.is_empty() {
       if let Some(alias) = &metadata.alias {
         deps = find_dependency(manifest, alias, metadata.kind);
-        name.clone_from(alias)
+        name.clone_from(alias);
       }
     }
 

+ 1 - 1
core/tauri-utils/src/lib.rs

@@ -295,7 +295,7 @@ pub struct Env {
 #[allow(clippy::derivable_impls)]
 impl Default for Env {
   fn default() -> Self {
-    let args_os = std::env::args_os().skip(1).collect();
+    let args_os = std::env::args_os().collect();
     #[cfg(target_os = "linux")]
     {
       let env = Self {

+ 2 - 1
core/tauri/src/process.rs

@@ -76,7 +76,8 @@ pub fn restart(env: &Env) {
 
   if let Ok(path) = current_binary(env) {
     Command::new(path)
-      .args(&env.args_os)
+      // first arg is the binary name, must skip it
+      .args(env.args_os.iter().skip(1).collect::<Vec<_>>())
       .spawn()
       .expect("application failed to start");
   }