Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addMany has strange behavior for files with only one extension #370

Open
SupernaviX opened this issue Mar 8, 2023 · 2 comments · May be fixed by #371
Open

addMany has strange behavior for files with only one extension #370

SupernaviX opened this issue Mar 8, 2023 · 2 comments · May be fixed by #371

Comments

@SupernaviX
Copy link

Hi!

I was trying to use plop to scaffold a new server, and I saw that addMany had some strange behavior on dockerfiles. When my template directory contained a Dockerfile.hbs and Dockerfile.test.hbs, the target directory contains Dockerfile.hbs and Dockerfile.test. Plop strips the extension from the test file, but not the main one.

I think the reason is that the main file only has the .hbs extension. Looking at the implementation, it looks like extension stripping only works if there's still an extension left after the .hbs is removed.

Is this a bug? Or is it a feature? And either way, would you accept a pull request to change that behavior?

@amwmedia
Copy link
Member

I looked at the implementation and I agree that it doesn't seem right. I'm not sure why we have it check to be sure there's an extension after the strip happens. Maybe there was an assumption that a no-extension file is not a valid state?

@SupernaviX
Copy link
Author

SupernaviX commented Mar 11, 2023

Yeah, looking at the original issue and original PR it looks like the behavior was intentional. The author called it out in their examples and tests.

I think that making it so that stripExtensions: ['hbs'] turns 'Dockerfile.hbs' -> 'Dockerfile' is a straightforward improvement. But this would definitely be a breaking change for stripExtensions: true (I'm not totally sure why you'd ever have so many template extensions you couldn't just list them, but someone thought it was worth it to build that option).

I think I'll raise a PR to update the behavior when stripExtensions is an array, but preserve existing behavior if it's a boolean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants