0

I am developing a VSCode extension that provide tasks, how can I specify that a property can change per platform, for example on "shell" task we can have this tasks.json:

"tasks": [
{
    "type": "shell",
    "windows": { "command": "wndCmd.exe" },
    "linux": { "command": "lnxCmd" },
    "osx": { "command": "osxCmd" }
}]

but for mine it is not possible.

From the sample on documentation, it is not possible create a task like:

"tasks": [
{
    "type": "rake",
    "task": "some",
    "windows": { "file": "winFile" },
    "linux": { "file": "linuxFile" },
    "osx": { "file": "osxFile" }
}]
Perry
  • 1,113
  • 2
  • 10
  • 22

2 Answers2

0

I don't really see a reason why you would need to do that for dynamically generated tasks, that only makes sense for declarative / static task declarations.

Just generate the version of the task that's appropriate for the current OS. You can check process.platform for that, see also:

Gama11
  • 31,714
  • 9
  • 78
  • 100
  • My task is a wrapper for an external build system, so I want allow the user set different options for different platform, It is not so extraterrestrial... – Perry Feb 24 '20 at 22:13
  • There's no such thing as "setting options" for generated tasks. https://github.com/microsoft/vscode/issues/58836 – Gama11 Feb 24 '20 at 22:20
  • thinking about It I understand that I can simply do it by hand... – Perry Feb 25 '20 at 05:31
0

I can do it by hand:

"taskDefinitions": [
    {
        "type": "rake",
        "required": [
            "task"
        ],
        "properties": {
            "task": {
                "type": "string",
                "description": "The Rake task to customize"
            },
            "file": {
                "type": "string",
                "description": "The Rake file that provides the task. Can be omitted."
            },
            "windows: {
                "type": "object",
                "properties": {
                    "file": {
                        "type": "string",
                        "description": "..."
                    }
                }
            },
            "linux: {
                "type": "object",
                "properties": {
                    "file": {
                        "type": "string",
                        "description": "..."
                    }
                }
            },
            "osx: {
                "type": "object",
                "properties": {
                    "file": {
                        "type": "string",
                        "description": "..."
                    }
                }
            }
        }
    }
]
Gama11
  • 31,714
  • 9
  • 78
  • 100
Perry
  • 1,113
  • 2
  • 10
  • 22
  • I'm not sure that does what you think it does. These are just the properties that "identify" a generated task, they can't be configured by users. See also that issue I linked earlier. – Gama11 Feb 25 '20 at 07:58
  • this code is tested, and work as expected https://github.com/APerricone/harbourCodeExtension/blob/636fc8ad86cd5d4e6e80d8d46bf401a849466786/client/package.json#L438 – Perry Feb 25 '20 at 19:47