-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplopfile.js
More file actions
40 lines (35 loc) · 1.24 KB
/
plopfile.js
File metadata and controls
40 lines (35 loc) · 1.24 KB
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
/* eslint-disable @typescript-eslint/no-var-requires */
const inquirerFuzzyPath = require("inquirer-fuzzy-path");
const storyGenerator = require("./src/generators/story");
module.exports = function (plop) {
plop.setGenerator("stories", storyGenerator);
//#region //*=========== Handlebars Helper ===========
/**
* Generate story component route
* @see https://stackoverflow.com/questions/41490076/capitalize-every-letter-after-and-characters
*/
plop.setHelper("directoryCase", function (title) {
return title.replace(/(^|\/|-)(\S)/g, (s) => s.toUpperCase());
});
/**
* Remove 'src', and file name from path
*/
plop.setHelper("getFolder", (path) => {
const split = path.split("/");
// remove filename
split.pop();
if (split[0] === "src") split.splice(0, 1);
return split.join("/");
});
/**
* Get file name from path, removing .tsx prefix
*/
plop.setHelper("getName", (path) => {
const split = path.split("/");
return split[split.length - 1].replace(/\.tsx$/, "");
});
//#endregion //*======== Handlebars Helper ===========
//#region //*=========== Inquirer Prompt ===========
plop.setPrompt("fuzzypath", inquirerFuzzyPath);
//#endregion //*======== Inquirer Prompt ===========
};