Advertisement
Guest User

Untitled

a guest
May 25th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. module.exports = function (plop) {
  2.  
  3. /* Helpers */
  4. plop.addHelper('upperCase', function (text) {
  5. return text.toUpperCase();
  6. });
  7.  
  8. /* Files */
  9. var createIndex = {
  10. type: 'add',
  11. path: 'src/components/{{pascalCase name}}/index.js',
  12. templateFile: 'templates/index.js'
  13. };
  14.  
  15. var createStyle = {
  16. type: 'add',
  17. path: 'src/components/{{pascalCase name}}/styles.js',
  18. templateFile: 'templates/styles.js'
  19. }
  20.  
  21. var createContainer = {
  22. type: 'add',
  23. path: 'src/components/{{pascalCase name}}/container.js',
  24. templateFile: 'templates/container.js'
  25. }
  26.  
  27. /* Questions */
  28. var getComponentName = {
  29. type: 'input',
  30. name: 'name',
  31. message: 'What is the component name?',
  32. validate: function (value) {
  33. if ((/.+/).test(value)) {
  34. return true;
  35. }
  36. return 'name is required';
  37. }
  38. };
  39.  
  40. var getContainerName = {
  41. type: 'input',
  42. name: 'stateName',
  43. message: 'What is the name of the state?',
  44. validate: function (value) {
  45. if ((/.+/).test(value)) {
  46. return true;
  47. }
  48. return 'name is required';
  49. }
  50. };
  51.  
  52. /* Options */
  53. plop.setGenerator('Component', {
  54. description: 'Component',
  55. prompts: [getComponentName],
  56. actions: [createIndex, createStyle]
  57. });
  58.  
  59. plop.setGenerator('Component with container', {
  60. description: 'Component with container',
  61. prompts: [getComponentName, getContainerName],
  62. actions: [createIndex, createStyle, createContainer]
  63. });
  64.  
  65. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement