plop icon indicating copy to clipboard operation
plop copied to clipboard

stripExtensions doesn't work with dot files

Open rwacarter opened this issue 5 years ago • 6 comments

I have, for example, a folder with a .babelrc and a package.json file in it. However, I'd like to pass some values into these files so I rename them .babelrc.hbs and package.json.hbs respectively.

Then when using them as templateFiles with an addMany action, the package.json file is correctly renamed but the .babelrc.hbs still has the hbs suffix.

Unless I'm missing something, this is hopefully solved by adding a simple check to the stripExtensions function, to make sure hidden files are included. I'd be happy to look into this and submit a pull request if that's the case.

rwacarter avatar Jun 23 '20 13:06 rwacarter

Any update on this? It is currently preventing me from using this package, as I can't copy .gitattributes, .gitignore, .prettierrc, .eslintrc files, etc, if they require variables. I have fixed the issue in https://github.com/plopjs/node-plop/pull/192.

rwacarter avatar Nov 02 '20 20:11 rwacarter

I have the same problem with .gitignore.hbs

JacekKosciesza avatar May 10 '21 12:05 JacekKosciesza

A workaround is to rename the files and add some fake placeholder, like this: {{fake}}.eslintrc.hbs

This will copy the file, remove the extension, and try to replace fake, but since it does not exsist as a variable, the result will be: .eslintrc

knikolov-nuvolo avatar Oct 26 '21 13:10 knikolov-nuvolo

it appears if only one file has one extension (e.g. y.hbs)

ls templates -a
.x.hbs  a.b.c.hbs  y.hbs

generated files:

.x.hbs  a.b.c  y.hbs

smmoosavi avatar Nov 21 '21 17:11 smmoosavi

Transfering this issue to https://github.com/plopjs/plop/ since we're migrating all of node-plop to that repo as a monorepo

crutchcorn avatar Apr 25 '22 22:04 crutchcorn

appreciate the fix @knikolov-nuvolo , this solved my issue

oneezy avatar Sep 06 '22 06:09 oneezy