SamKirkland / plop-templates

VSCode extension for plop.js file templates
MIT License
22 stars 5 forks source link

Add support for multi-root workspace folder aliases #10

Open villecoder opened 4 years ago

villecoder commented 4 years ago

It would be nice if the extension would support multi-root workspaces. Given the following directory structure, I'd like to make the following proposal:

Directory structure

Root
| - Shared.Project/
| - - SharedProject.csproj
| - - Templates/
| - - - plopfile.js
|
| - Project.A/
| - - ProjectA.csproj
|
| - Project.B/
| - - ProjectB.csproj
|
| - workspace.code-workspace

workspace.code-workspace (proposed)

{
  "folders": [
    { "name": "shared", "path": "./Shared.Project" },
    { "name": "A", "path": "./Project.A" },
    { "name": "B", "path": "./Project.B" }
  ],
  "settings": {
    "plopTemplates.configFileName": "{$workspaceFolder:shared}/templates/plopfile.js" 
    "plopTemplates.plopCommand": "plop --plopfile ${workspaceFolder:shared}/templates/plopfile.js"
  }
}

The current workaround is to specify the configFileName and plopCommand relative to the opening terminal. As you can see, in a multi-root environment that isn't always tenable.

SamKirkland commented 4 years ago

Hello,

I haven't used multi-root workspaces yet but this seems like a useful feature to support.

Can you help me understand what would need to change on the extension side to support this? Is the request to make the configuration changes you've done happen automatically?

Thanks!

villecoder commented 3 years ago

I just noticed that you followed up, Sam. After reading this, I realize what my question was really trying to deal with. I think the issue is that I don't understand how to send your extension the path to the plopfile if the plopfile is not in the root of the workspace.

So I'm using the code-workspace syntax for a folder alias to specify the directory to work from. You would need to search the WorkspaceFolder array for the named alias and then use the path value from that.