Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/derekseverson/plop-pack-rename-many
A plop helper for renaming multiple files via a glob pattern
https://github.com/derekseverson/plop-pack-rename-many
Last synced: 5 days ago
JSON representation
A plop helper for renaming multiple files via a glob pattern
- Host: GitHub
- URL: https://github.com/derekseverson/plop-pack-rename-many
- Owner: DerekSeverson
- License: mit
- Created: 2019-10-10T14:22:31.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-10T11:20:41.000Z (over 3 years ago)
- Last Synced: 2024-11-09T12:49:27.087Z (7 days ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# plop-pack-rename-many
> plop helper for renaming multiple files via a glob pattern
## Motivation
My main issue was that I didn't want hidden/dot files (ex: .gitignore, .npmrc, .babelrc, .eslintrc, .gitlab-ci.yml, etc.) in my templates folder because they actually change how my repository functions in that directory.
Here's some examples:
1. My templates/.eslintrc file now causes many of my javascript files in my templates directory to have linting errors because they have handlebars syntax for injecting data.
2. My templates/.gitignore file now ignores some of the template files that I actually don't want ignored any more.So, I wrote this custom `renameMany` action (`plop-pack-rename-many`).
Not only that, but the renaming action can be used for things other than just hidden/dot files.
## Example
```javascript
// plopfile.jsmodule.exports = (plop) => {
plop.load('plop-pack-rename-many')
plop.setGenerator('generatory-name-here', {
actions: [
{
type: 'addMany',
destination: process.cwd(),
templateFiles: './templates/**/*',
globOptions: { dot: true },
base: './templates',
force: true
},
{ // converts filenames starting with an underscore to dot files.
type: 'renameMany', // <-- the plop-pack-rename-many action!
templateFiles: `${process.cwd()}/**/_*`, // glob pattern to select all files starting with an underscore.
renamer: name => `.${name.slice(1)}` // rename by removing the underscore and add the period.
}
]
})
}
```