-
Notifications
You must be signed in to change notification settings - Fork 2
/
plopfile.cjs
41 lines (39 loc) · 1.13 KB
/
plopfile.cjs
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
39
40
41
// eslint-disable-next-line no-undef
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: () => [
{
type: 'addMany',
base: 'plop-templates/hook',
templateFiles: 'plop-templates/hook/*.*',
destination: `src/hooks/{{camelCase hookName}}/`,
},
{
type: 'append',
path: 'src/index.ts',
// eslint-disable-next-line prefer-named-capture-group
pattern: /(\/\* plop_add_export \*\/)/giu,
template: `export * from './hooks/{{camelCase hookName}}/{{camelCase hookName}}.js';`,
},
],
});
};