New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resolving multiple tasks with type npm and same script fails #93001
Comments
(Experimental duplicate detection) |
Workaround would be to simply define a separate script in package.json for each task |
This is by design. An extension provided task, such as a task of Since this is very easily worked around by having a separate npm script in your package.json I wouldn't make any changes in the behavior. However, it is not nice that the first time you learn that you can't have two of the same task is when you try to run a task that depends on it. I will add an error earlier, so that it's clear what's happening when the task list shows. |
@alexr00 I just hit this today as well, in my situation both script calls had different working directories:
In my case I don't really have ownership of the web/client and web/server package.json files, so renaming or adding script sections is not an option... |
Workaround: add a path property and use '.', or './.' or '././.' etc. |
@alexr00 would it be possible to include the options (particularly cwd) in the unique identification of a task? I just ran into this while trying to configure build tasks in an npm workspace where the sub-workspaces had identically named scripts with different cwds. As you note, it's easy to work around this, but it was definitely surprising behavior and I wasted time trying to figure out what I'd misconfigured. |
It's not possible with the way that the tasks system is currently implemented. The npm extension already provides a way to do this without renaming scrips using the |
My workaround is to just add spaces to the script name:
Also, on @alexr00 point:
That's not entirely true. I also don't think this is a "polish" issue. Having to add spaces is a sloppy workaround, and it's confusing trying to integrate |
After a lot of digging, it seems
Basically, it creates an identifier, and then a keyed one based on its properties:
Since the fields passed aren't unique enough, the key is duplicated and only the last entry will persist when it eventually moves to a It also seems this bug isn't just Edit: Oh, I think I'm wrong about some of that. Basically, |
Workaround of using spaces no longer works as of v1.66.2 :( |
I just hit this in the TS repo, where I'm changing our build but leaving some tasks behind for backwards compat. I had:
We don't commit launch.json, but we do commit tasks.json, so I was leaving an old task behind as to not cause breakage for the people on my team with old launch configs. But, when I opened the task menu, I only saw the latter open. The "fix" for me was to move the deprecated gulp task to the top (with a big explanatory comment), as the last use of a script is the one that appears to win. Obviously, this only works because I am content with just one of the scripts showing up, and we don't set cwd or anything. |
@alexr00 @meganrogge If an external contributor wanted to try and fix this what would be the next steps? |
Issue Type: Bug
Create 2 tasks with "type": "npm" and same "script"
Expected both tasks to be resolved by their label
tasks.json:
package.json:
VS Code version: Code 1.43.1 (fe22a96, 2020-03-18T07:01:20.184Z)
OS version: Windows_NT x64 10.0.19041
System Info
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
The text was updated successfully, but these errors were encountered: