Closed omniscient closed 3 years ago
I believe that ${workspaceRootFolderName}
solves your problem.
The whole list of variables can be found here https://code.visualstudio.com/docs/editor/tasks#_variable-substitution
If none of them solve your issue than please let me know for the path /a/b/c/d/e.txt and the repository is /a/b what do you want extracted with the variable
@isidorn Thanks for your quick response on this. As identified above, we are already using the ${workspaceRoot}
variable which is identical to ${workspaceRootFolderName}
in that it actually returns the root directory. In a git mono repo, you have multiple root, one for each package. By default, a mono repo has a folder into which all package (what would equate to a single git repo) lives in. The standard i've seen is to create subfolder named packages
. Under that 'packages' folder lives each different component. There is really 2 things I think for this to work.
Let's take my example above. On my system I have my git repository in c:\git\myrepo
. Within the myrepo
git repository, I have a structure as identified above:
myrepo
package.json
Packages
api
package.json
src
dist
orm
package.json
src
dist
Given the above example, that means I have c:\git\myrepo\packages
set as my root for every different package that I manage in that mono repo. In the example, my mono repo handles 2 different packages that are in the following folders on my system:
api
which lives in c:\git\myrepo\packages\api
orm
which lives in c:\git\myrepo\packages\orm
The request is that in launch.json, I have access to a new variable $(packageRoot}
that knows that when I got a file open under the api
project, for example c:\git\myrepo\packages\api\src\__test\blabla.ts
, the new variable returns c:\git\myrepo\packages\api
. Similarly, when I have a file open in the orm
project, that new variable would return c:\git\myrepo\packages\orm
Hope this makes sense, let me know if you need more information.
@omniscient thanks for providing more information however what you seem to be needing seems very specific for mono debugging. On the VSCode side we are language agnostic and do not provide any variable subsitition that is speicifc for some language. This should in theory be handled by the mono debug extension, however our current extension API is not strong enough to support this use case.
Due to the following leaving this open as a feature request and assiging to backlog.
@isidorn : I am sorry to have to digress here but to be 100% clear, nowhere did I mention a programming language of any sort. What I am talking about is monolithic version control using git.
Would you mind taking a 2nd look at this with that fact in mind? I would really appreciate if you could at least indicate where/what would need to be changed and how, at a high-level, it could done? Maybe I could PR it for you guys if it's not too bad?
Once again, we are talking about a way to identify, that 1, we are dealing with a mono repo and 2, we have a variable that identifies the packages root folder.
Thanks for additional clarification. This sounds like a very speicifc feature request.
We accept PRs, however keep in mind that if it is too complex or too language specific we will not accept it. Also keep in mind that we currently have no code that detects the type of a repo. Due to that I believe this would be hard to do.
Would https://github.com/Microsoft/vscode/issues/25786 get the job done? It helps to get into the relative nested folders.
I think there is a way you can do this already.
"terminal.integrated.env.linux": {
"packagePath": "packages"
},
{
"type": "node",
"request": "launch",
"name": "Debug unit test with tape",
"sourceMaps": true,
"protocol": "inspector",
"stopOnEntry": false,
"program": "${workspaceRoot}/node_modules/tape/bin/tape",
"args": [
"${workspaceRoot}/${env:packagePath}/dist/_test/**/${fileBasenameNoExtension}.js"
],
"cwd": "${workspaceRoot}/${env:packagePath}",
"console": "internalConsole"
}
In the spirit of https://github.com/Microsoft/vscode/issues/396, please consider adding a new variable that can be used in launch.json and that will refer to the package directory (
packageRoot
) of the currently opened file within the editor.This is going to be useful to reduce the number of profiles necessary to debug each package. As an example, here's what we have to do currently such that we can debug our tape unit tests directly from the code editor:
Given that we have a mono repo structure like this:
Given we develop in Typescript and we resolve the current file name using
${fileBasenameNoExtension}
, Given we have both a "api" package and a "orm" package in a git mono repo, We are stuck doing this to debug our tests inside the code editor:The request is for a variable that identifies the root directory of each package so that we could re-write our launch.json like this: