Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = function (plop) {
- /* Helpers */
- plop.addHelper('upperCase', function (text) {
- return text.toUpperCase();
- });
- /* Files */
- var createIndex = {
- type: 'add',
- path: 'src/components/{{pascalCase name}}/index.js',
- templateFile: 'templates/index.js'
- };
- var createStyle = {
- type: 'add',
- path: 'src/components/{{pascalCase name}}/styles.js',
- templateFile: 'templates/styles.js'
- }
- var createContainer = {
- type: 'add',
- path: 'src/components/{{pascalCase name}}/container.js',
- templateFile: 'templates/container.js'
- }
- /* Questions */
- var getComponentName = {
- type: 'input',
- name: 'name',
- message: 'What is the component name?',
- validate: function (value) {
- if ((/.+/).test(value)) {
- return true;
- }
- return 'name is required';
- }
- };
- var getContainerName = {
- type: 'input',
- name: 'stateName',
- message: 'What is the name of the state?',
- validate: function (value) {
- if ((/.+/).test(value)) {
- return true;
- }
- return 'name is required';
- }
- };
- /* Options */
- plop.setGenerator('Component', {
- description: 'Component',
- prompts: [getComponentName],
- actions: [createIndex, createStyle]
- });
- plop.setGenerator('Component with container', {
- description: 'Component with container',
- prompts: [getComponentName, getContainerName],
- actions: [createIndex, createStyle, createContainer]
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement