Home > Enterprise >  vscode tasks.json transform pickfile
vscode tasks.json transform pickfile

Time:12-21

I have next vscode tasks.json

{
"version": "2.0.0",
"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "${userHome}/build.py",
        "args": ["param_def=${input:pickBuild}"]
    }
],
"inputs": [
    {
      "id": "pickBuild",
      "type": "command",
      "command": "extension.commandvariable.file.pickFile",
      "args": {
        "include": "**/default_*.py",
        "description": "Select build",
        "display": "fileName",
      }
    }
]}

when run:

actual: /home/user/build.py param_def=/home/user/default_android.py

expected: /home/user/build.py param_def=default_android

P.S: I have tried use extension.commandvariable.transform, but did not success

CodePudding user response:

You can use the following config in your tasks.json

{
"version": "2.0.0",
"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "${userHome}/build.py",
        "args": ["param_def=${input:pickBuild}"]
    }
],
"inputs": [
    {
      "id": "pickBuild",
      "type": "command",
      "command": "extension.commandvariable.transform",
      "args": {
        "text": "${pickFile:build}",
        "find": "^.*/(.*).py",
        "replace": "$1",
        "pickFile": {
          "build": {
            "include": "**/default_*.py",
            "description": "Select build",
            "display": "fileName",
          }
        }
      }
    }
]}
  • Related