Skip to content

Commit

Permalink
chore(plop): add component's role option
Browse files Browse the repository at this point in the history
  • Loading branch information
aneurysmjs committed Apr 29, 2019
1 parent 626e85b commit 8965ff1
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions plopfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ module.exports = function(plop) {
'functional',
]
},
{
type: 'list',
name: 'componentRole',
message: 'Choose component\'s role',
choices: [
'base',
'core',
'shared'
],
default: 'shared',
},
{
type: 'confirm',
name: 'connectToRedux',
Expand All @@ -28,23 +39,24 @@ module.exports = function(plop) {
when: ({ componentType }) => !isFunctional(componentType),
},
],
actions({ componentType }) {
actions({ componentType, componentRole }) {
const prefix = isFunctional(componentType) ? 'functional-' : 'class-';
const role = componentRole;

const actions = [
{
type: 'add',
path: `${components}/shared/{{properCase componentName}}/{{properCase componentName}}.js`,
path: `${components}/${role}/{{properCase componentName}}/{{properCase componentName}}.js`,
templateFile: `./config/plop/component/${prefix}component.js.plop`,
},
{
type: 'add',
path: `${components}/shared/{{properCase componentName}}/{{properCase componentName}}.scss`,
path: `${components}/${role}/{{properCase componentName}}/{{properCase componentName}}.scss`,
templateFile: './config/plop/component/component.scss.plop',
},
{
type: 'add',
path: `${components}/shared/{{properCase componentName}}/{{properCase componentName}}.test.js`,
path: `${components}/${role}/{{properCase componentName}}/{{properCase componentName}}.test.js`,
templateFile: './config/plop/component/component.test.js.plop',
},
];
Expand Down

0 comments on commit 8965ff1

Please sign in to comment.