-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.js
40 lines (37 loc) · 1.05 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
39
40
module.exports = function (plop) {
// create your generators here
plop.setGenerator("Component", {
description: "Generate a new component along with the CSS",
prompts: [
{
type: "input",
name: "name",
message:
"The name of the files eg (my-component). This will also be used to name the component",
},
],
actions: [
{
type: "add",
path: "components/{{name}}/{{name}}.module.css",
templateFile: "plop-templates/component/module.css",
},
{
type: "add",
path: "components/{{name}}/{{name}}.js",
templateFile: "plop-templates/component/component.js.hbs",
},
],
});
plop.setHelper("componentName", (txt) => makeCamelCase(txt));
};
// this-is-an-example => ThisIsAnExample
function makeCamelCase(str) {
const arr = str.split("-");
const capital = arr.map(
(item) => item.charAt(0).toUpperCase() + item.slice(1).toLowerCase()
);
// ^-- change here.
const capitalString = capital.join("");
return capitalString;
}