vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Tasks running same npm script in other cwd are ignored and "don't exist"

Open Deathspike opened this issue 1 year ago • 2 comments

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.86.2
  • OS Version: Windows_NT x64 10.0.22631

Steps to Reproduce:

  1. Use the following tasks.json:
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "service.a",
      "options": {"cwd": "${workspaceFolder}/packages/service.a"},
      "script": "example",
      "type": "npm"
    },
    {
      "label": "service.b",
      "options": {"cwd": "${workspaceFolder}/packages/service.b"},
      "script": "example",
      "type": "npm"
    }
  ]
}
  1. Try running service.a task. It won't exist.

Expected behavior:

I expect both tasks to exist and be able to get launched. It seems that service.b overwrites service.a because both run example script, but the task manager doesn't seem to understand that the options are different (different cwd). To work around this, I need to name scripts different, which causes issues for a monorepo structure.

Deathspike avatar Feb 18 '24 13:02 Deathspike

If you want to run both tasks simultaneously, you can create a new task that runs both tasks in parallel. Here's an example of how you can do this:

{ "version": "2.0.0", "tasks": [ { "label": "service.a", "options": {"cwd": "${workspaceFolder}/packages/service.a"}, "script": "example", "type": "npm" }, { "label": "service.b", "options": {"cwd": "${workspaceFolder}/packages/service.b"}, "script": "example", "type": "npm" }, { "label": "service.a and service.b", "dependsOn": ["service.a", "service.b"], "type": "parallel" } ] }

akyllus avatar Feb 18 '24 14:02 akyllus

If you want to run both tasks simultaneously, you can create a new task that runs both tasks in parallel. Here's an example of how you can do this:

That is not what this bug report is about. Besides that, your snippet doesn't even work. The bug still exists, making service.a non-existent, and type = parallel doesn't exist either.

Deathspike avatar Feb 18 '24 16:02 Deathspike

/duplicate #93001

meganrogge avatar Feb 29 '24 21:02 meganrogge