Jelajahi Sumber

fix(core): resolve base dir in shell scope, closes #5480 (#5508)

Amr Bashir 2 tahun lalu
induk
melakukan
99fe1c562f

+ 5 - 0
.changes/shell-resolve-base-dirs.md

@@ -0,0 +1,5 @@
+---
+"tauri": "patch"
+---
+
+Resolve base system directory in shell scope.

+ 1 - 1
core/tauri/src/app.rs

@@ -1555,7 +1555,7 @@ impl<R: Runtime> Builder<R> {
       #[cfg(http_request)]
       http: crate::scope::HttpScope::for_http_api(&app.config().tauri.allowlist.http.scope),
       #[cfg(shell_scope)]
-      shell: ShellScope::new(shell_scope),
+      shell: ShellScope::new(&app.manager.config(), app.package_info(), &env, shell_scope),
     });
     app.manage(env);
 

+ 12 - 1
core/tauri/src/scope/shell.rs

@@ -8,6 +8,7 @@ use crate::api::process::Command;
 use crate::api::shell::Program;
 
 use regex::Regex;
+use tauri_utils::{config::Config, Env, PackageInfo};
 
 use std::collections::HashMap;
 
@@ -193,7 +194,17 @@ pub enum ScopeError {
 
 impl Scope {
   /// Creates a new shell scope.
-  pub(crate) fn new(scope: ScopeConfig) -> Self {
+  pub(crate) fn new(
+    config: &Config,
+    package_info: &PackageInfo,
+    env: &Env,
+    mut scope: ScopeConfig,
+  ) -> Self {
+    for cmd in scope.scopes.values_mut() {
+      if let Ok(path) = crate::api::path::parse(config, package_info, env, &cmd.command) {
+        cmd.command = path;
+      }
+    }
     Self(scope)
   }