-
Notifications
You must be signed in to change notification settings - Fork 2
/
plopfile.mjs
56 lines (55 loc) · 1.33 KB
/
plopfile.mjs
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
export default function (plop) {
plop.setGenerator('createFn', {
description: 'Create New Fn',
prompts: [
{
type: 'input',
name: 'name',
message: '函数名(必填)',
default: 'doSomething',
validate: function(input) {
if (input === 'doSomething') {
return false;
}
return true;
}
},
{
type: 'input',
name: 'description',
message: '一句话描述'
}
],
actions: [
// Create SourceCode and Unit Test
{
type: 'addMany',
destination: 'packages/{{name}}',
base: 'plop-templates/newFn',
templateFiles: ['plop-templates/newFn/*.ts.hbs']
},
// Create Doc
{
type: 'add',
path: 'docs/{{name}}.md',
templateFile: 'plop-templates/newFn/doc.md.hbs'
},
// import newFn
{
type: 'modify',
path: 'packages/index.ts',
pattern: /(\/\/ IMPORT_PLACEHOLDER--DO_NOT_REMOVE)/g,
template: 'import {{name}} from \'./{{name}}\';\n$1',
type: 'modify'
},
// export newFn
{
type: 'modify',
path: 'packages/index.ts',
pattern: /(\/\/ EXPORT_PLACEHOLDER--DO_NOT_REMOVE)/g,
template: '{{name}},\n $1',
type: 'modify'
}
]
});
}