Skip to content

Commit

Permalink
fix: plop generation
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Apr 13, 2022
1 parent 3cfe0e8 commit b20be92
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions plopfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ const camelCase = (str) => {
return str.replace(/[-_]([a-z])/g, (g) => g[1].toUpperCase())
}

const capitalize = (str) => {
return str.charAt(0).toUpperCase() + str.slice(1)
}

/**
* @param {import("plop").NodePlopAPI} plop
*/
module.exports = function main(plop) {
plop.setHelper("camelize", camelCase)
plop.setHelper("capitalize", capitalize)

plop.setGenerator("machine", {
description: "Generates a new ui machine",
Expand All @@ -26,9 +31,9 @@ module.exports = function main(plop) {

actions.push({
type: "addMany",
templateFiles: "machine/**",
destination: `../packages/machines/{{dashCase machine}}`,
base: "machine/",
templateFiles: "plop/machine/**",
destination: `packages/machines/{{dashCase machine}}`,
base: "plop/machine/",
data: { machine, name: machine },
abortOnFail: true,
})
Expand Down Expand Up @@ -60,9 +65,9 @@ module.exports = function main(plop) {

actions.push({
type: "addMany",
templateFiles: "utility/**",
destination: `../packages/utilities/${name}`,
base: "utility/",
templateFiles: "plop/utility/**",
destination: `packages/utilities/{{dashCase name}}`,
base: "plop/utility/",
data: { description, name },
abortOnFail: true,
})
Expand Down

0 comments on commit b20be92

Please sign in to comment.