-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathplopfile.js
35 lines (33 loc) · 909 Bytes
/
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
/**
* @param {import("plop").NodePlopAPI} plop
*/
module.exports = function main(plop) {
plop.setHelper("camelize", (txt) => {
return txt.replace(/[-_]([a-z])/g, (g) => g[1].toUpperCase())
})
plop.setGenerator("snippet", {
prompts: [
{
type: "input",
name: "component",
message: "Enter machine name (e.g. menu, popover):",
},
],
actions(answers) {
const actions = []
if (!answers) return actions
const { component } = answers
const frameworks = ["react", "vue", "solid"]
frameworks.forEach((framework) => {
actions.push({
type: "addMany",
templateFiles: `./plop/snippet/${framework}/**`,
destination: `./data/snippets/${framework}/${component}`,
base: `./plop/snippet/${framework}`,
data: { component },
})
})
return actions
},
})
}