Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

typescript - Unifying multiple vscode debug configs into one

I have a project with the following folder structure:

server
    somepackage
        src
            subpackage
                file.ts
        test
            subpackage
                file.spec.ts
    someotherpackage
        src
            file1.ts
        test
            file1.spec.ts
.vscode/launch.json

If I want to be able to debug the current file, in .vscode/launch.json, I need to create two configs with "TS_NODE_PROJECT": "${fileDirname}/../tsconfig.json" and "TS_NODE_PROJECT": "${fileDirname}/tsconfig.json", and to debug we will need to choose the appropriate config in the vscode debugger. Is there a way to do this with a single config. Can I say: TS_NODE_PROJECT = dir1/tsconfig.json and if it does not exist then it is dir2/tsconfig.json?

question from:https://stackoverflow.com/questions/65915073/unifying-multiple-vscode-debug-configs-into-one

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

With the extension Command Variable you can create part of a property based on the file path

....

    "TS_NODE_PROJECT": "${fileDirname}${input:bypath}/tsconfig.json"

....

  "inputs": [
    {
      "id": "bypath",
      "type": "command",
      "command": "extension.commandvariable.file.fileAsKey",
      "args": {
        "/somepackage/": "",
        "/someotherpackage/": "/.."
      }
    }
  ]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...