Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[idea] call other actions in custom actions (setActionType) #103

Open
macrozone opened this issue Jan 5, 2018 · 3 comments
Open

[idea] call other actions in custom actions (setActionType) #103

macrozone opened this issue Jan 5, 2018 · 3 comments

Comments

@macrozone
Copy link
Collaborator

In custom action, it should be possible to call an array of other actions.

e.g.

plop.setActionType('component-with-tests-and-stories', (answers, config) =>  {
	return plop.executeActions([
		{
			type: 'add',
			path: "./components/{{name}}.js",
			templateFile: config.componentTemplate
		},
		{
			type: 'add',
			path: "./components/stories/{{name}}.story.js",
			templateFile: config.storyTemplate
		},
		{
			type: 'add',
			path: "./components/tests/{{name}}.test.js",
			templateFile: config.testTemplate
		},
	
  ]
});

Then one can use that to define multiply different component generators, e.g. for ui primitives, layouts or more complex components, but all are created with a storybook story and a test.

This would make setActionType much more powerful

@macrozone
Copy link
Collaborator Author

i did a pr for that: plopjs/node-plop#58

@amwmedia
Copy link
Member

amwmedia commented Jan 5, 2018

interesting idea... I'll take a look at your PR for the details

@bizoo
Copy link

bizoo commented Nov 27, 2018

This feature would be really useful.

I have to change encoding of all added files to win1252, so I've created a convert action to do the the job but I've to call it after each add action (dozen of files).
With this feature I can create a new addConvert action that call the add and convert actions by itself.

Or is it possible to check the return value of the function defined by setActionType and if it's an array, insert it in the current actions array (or add a new special standard action addAction that return an array of actions for this purpose) ?

cspotcode pushed a commit to cspotcode/plop that referenced this issue Mar 20, 2020
…er-0.0.44

Update @types/inquirer to the latest version 🚀
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants