Base path with relative path fails to find templates
Hi. I am using plop to generate a lot of boilerplate for my projects and it works great. Just encountered a scenario where,
THIS WORKS
{
type: "addMany",
destination: "./path/to/{{camelCase name}}",
base: `my/templates`,
templateFiles: "my/templates/**/*",
stripExtensions: ["txt"],
verbose: true,
}
THIS DOES NOT WORK
{
type: "addMany",
destination: "./path/to/{{camelCase name}}",
base: `./my/templates`,
templateFiles: "my/templates/**/*",
stripExtensions: ["txt"],
verbose: true,
}
The only difference is the prefix of ./ in the base config and plop is not able to find any files when using that. I am not sure if it is intended but thought i would let you know.
Hi, I’m interested in contributing and would like to work on this issue. Could you please confirm if it’s okay for me to pick it up?
Hi, just following up on this issue. I’m still interested in contributing and would love to work on it. Please let me know if it’s okay to start.
I say go for it 👍🏻
Thank you. I'll get started on it!
I tested the behavior of addMany with and without the base property, including using ./ as a prefix. Specifically, I created a generator like this:
actions: [
{
type: "addMany",
base: "./templates/components", // tried with and without "./"
destination: "output",
templateFiles: "templates/**/*.txt",
},
]
When running the generator, Plop correctly found the template files and processed them in both cases. The ./ prefix did not affect file resolution.
It seems that Plop automatically calculates a “virtual base” from the glob pattern, which may explain why the explicit base is sometimes optional.
Conclusion: From my testing, the issue described does not reproduce on the current version. Please correct me if I missed something or tested it incorrectly.