-
Notifications
You must be signed in to change notification settings - Fork 1
/
plopfile.js
37 lines (36 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
module.exports = function(plop) {
plop.setGenerator('component', {
description: 'Component generator',
prompts: [
{
type: 'input',
name: 'hookName',
message: 'What is the name of your hook?',
validate: (value) => {
if (value.length === 0) return 'Please enter a hook name';
if (value.indexOf('use') !== 0)
return `The hook needs to start with 'use', for example: 'use${
value.charAt(0).toUpperCase() + value.slice(1)
}'`;
return true;
},
},
],
actions: () => {
return [
{
type: 'addMany',
base: 'plop-templates/hook',
templateFiles: 'plop-templates/hook/*.*',
destination: `src/{{camelCase hookName}}/`,
},
{
type: 'append',
path: 'src/index.ts',
pattern: /(\/\* PLOP_ADD_EXPORT \*\/)/gi,
template: `export * from './{{camelCase hookName}}/{{camelCase hookName}}';`,
},
];
},
});
};