plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

[v2] Shell Sidecars always run commands with args from tauri.conf.json when invoked with JS bindings

Open austenc opened this issue 2 years ago • 3 comments

When using a sidecar executable and invoking it with the Javascript bindings, the arguments defined in the tauri.conf.json file are always applied automatically. This doesn't happen when invoking it from the Rust side.

Example JS

const test = async () => {
    let cmd = Command.sidecar('my-sidecar')

     // this actually invokes `my-sidecar -v`
    await cmd.spawn()
}
test()

Given something like this in tauri.conf.json:

"plugins": {
    "shell": {
      "scope": [{
        "name": "my-sidecar",
        "sidecar": true,
        "args": [
          "-v",
        ]
      }]
    }
  },
  "tauri": {
    "bundle": {
      "active": true,
      "targets": "all",
      "identifier": "com.example.dev",
      "externalBin": [
        "php-server"
      ]
    },

austenc avatar Oct 28 '23 22:10 austenc

@lucasfernog looking at the code it looks like this is intentional? I kinda get it and i think my actual problem is not that behavior per se, but the scope config as a whole. Currently you have to configure multiple commands if you want to have different args per call which is a) a bit annoying and b) unexpected for the users from what i've heard so far.

Is this (=the scope as a whole here) something that will be changed with the allowlist change you guys are working on? Otherwise i feel like we'll need another discussion for this then.

FabianLars avatar Oct 30 '23 11:10 FabianLars

We didn't discuss this for the allowlist changes. I agree we should do something about it.

@chippers original idea was to make each scope object a "template" where you defined fixed arguments and dynamic ones, and supply the dynamic args at runtime. I think I changed it later to what we have right now.

lucasfernog avatar Oct 30 '23 11:10 lucasfernog