In launch.json I have a debug configuration that runs mocha for the current file:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Current File",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--timeout",
"999999",
"--colors",
"${file}"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
I am using typescript and the ts file is at folder src/... root whereas the test.js file is at folder root dist/... I want to have the ts file open, run the debug mocha configuration and have rewrite the src path to the dist path.
The following gets met almost there: "dist/${relativeFileDirname}/${fileBasenameNoExtension}.js"
but relativeFileDirname still contains src/... as the root. I need to do a regex replacement.
Extension Command Variable has more or less what I need but it does directory up patterns whereas I need directory down patterns, ie it can take src/folder1/folder2 and return src/folder1 whereas I want folder1/folder2.
CodePudding user response:
you can use the extension.commandvariable.transform
command.
"inputs": [
{
"id": "down1Dir",
"type": "command",
"command": "extension.commandvariable.transform",
"args": {
"text": "${relativeFileDirname}",
"find": ".*?/(.*)",
"replace": "$1",
}
}
]