vscode: task extending another task / passing parameters
Asked Answered
C

0

7

starting position

A tasks.json that defines a working build task (currently the only one, defined as default and working fine, also triggered by [CTRL]+[SHIFT]+[B]).

It triggers an external command (batch/shell script) and passes some parameters. Excerpt:

        {
            "label": "sample task",
            "windows": {
                "command": "${workspaceFolder}\\procedures_win\\doStuff.bat"
            },
            "linux": {
                "command": "${workspaceFolder}/procedures/doStuff.sh"
            },
            "type": "shell",
            "args": [
                "fixedParm",
                "${fileBasename}"
            ]
        }

(the complete one is much longer, mainly because of the amount of entries in the problemMatcher, contains target specific environment settings, 100 lines+ ...)

goal

Create a second task "sample task (check-only)" that is completely identical but passes one extra argument to the script "check-only".

options?

Is it possible to "extend" the given task "overriding" only the args?

If not: Is it possible to have a task actually run (not depend on) another task and setting an environment parameter that may then be used by the original task as "${env:someValue}" (an will either result to the empty string or the requested "check-only")?

As a last resort one possibly could define 5 instead of the two tasks (1 nearly identical to the current one, but taking an input from an external command/file; 2+3 meta tasks depending on 4+5, 4+5 command that creates a file ${workspaceFolder}/.taskmode that contains either nothing or "check-only").

question

How does a working solution without installing extensions look like?

Canning answered 8/5, 2020 at 11:36 Comment(2)
It sucks that no one has provided any kind of answer to this... I'm in the same position myself. Thus far I haven't found anything that can accomplish what you/we are looking for, but the VSCode documentation is both detailed and yet not very detailed...Couperin
@Couperin you possibly want to check if there's any option to not run a shell command but a a vscode command - because there is one for calling a task - and this may be able to either directly pass more arguments or set an environment var - finally providing the answer to this question. Also possibly a good idea: create a FR for this in the vscode issue tracker and see if someone says "that already works when you..." - or gets enough upvotes to ~rot~ shine in the backlog.Canning

© 2022 - 2024 — McMap. All rights reserved.