-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathplopfile.js
38 lines (37 loc) · 1.03 KB
/
plopfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module.exports = function (plop) {
plop.addHelper('lowerCase', (text) => text.toLowerCase());
plop.addHelper('properCase', (text) =>
text.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1);
}),
);
plop.setGenerator('component', {
description: 'Add a react component',
prompts: [
{
type: 'input',
name: 'name',
message: 'Component name please (ex: layout, breadcrumbs, menuItem)!',
},
],
actions: [
{
type: 'add',
path:
'src/lib/components/{{lowerCase name}}/{{properCase name}}.component.js',
templateFile: 'plop-templates/component.hbs',
},
{
type: 'add',
path:
'src/lib/components/{{lowerCase name}}/{{properCase name}}.component.test.js',
templateFile: 'plop-templates/component.test.hbs',
},
{
type: 'add',
path: 'stories/{{lowerCase name}}.stories.js',
templateFile: 'plop-templates/stories.hbs',
},
],
});
};