Skip to content

Commit

Permalink
fix(core): resolve base dir in shell scope, closes #5480 (#5508)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Nov 4, 2022
1 parent 9b1a6a1 commit 99fe1c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/shell-resolve-base-dirs.md
@@ -0,0 +1,5 @@
---
"tauri": "patch"
---

Resolve base system directory in shell scope.
2 changes: 1 addition & 1 deletion core/tauri/src/app.rs
Expand Up @@ -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);

Expand Down
13 changes: 12 additions & 1 deletion core/tauri/src/scope/shell.rs
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 99fe1c5

Please sign in to comment.