node-plop icon indicating copy to clipboard operation
node-plop copied to clipboard

allow to execute subactions

Open macrozone opened this issue 7 years ago • 9 comments

In plop.setActionType the third parameter ("plopfileApi") has now a new function as property

runActions(actions, data)

You can pass an array of actions, so that your custom action type will invoke all these actions as part of your custom action (like "child" actions)

See the tests or linked issue for an example.

solves https://github.com/amwmedia/plop/issues/103

error logging is a bit hacky, but show all infos from the sub actions as well.

macrozone avatar Jan 05 '18 13:01 macrozone

I love this feature! The only thing that is bugging me is that it makes the plopfileApi different in different contexts. Not sure that there's a way around this that doesn't give up functionality. I was thinking of just letting the action return an array of more actions to run, but then you can run code AFTER the sub-actions run.

Any thoughts?

amwmedia avatar Feb 01 '18 19:02 amwmedia

I think its worth it. Its not the most beautiful api, but it works and solve some issues

macrozone avatar Mar 05 '18 20:03 macrozone

I'm going to spend a little time with this... I think it needs to get merged in one form or another. :+1:

amwmedia avatar Mar 05 '18 20:03 amwmedia

i merged master back in. Hope you can take a look soon!

macrozone avatar Mar 12 '18 07:03 macrozone

any chance to get this merged? its tested and solves some issues

macrozone avatar Mar 18 '18 15:03 macrozone

yeah, I will try to get it in soon. I was reviewing the code and trying to work out a solution that doesn't create a variant API inside the action. Then life got crazy :-). I'm going to revisit it this week.

amwmedia avatar Mar 19 '18 13:03 amwmedia

@amwmedia any updates ;-) i know, its not the best to reinvent a new api, but its a pragmatic approach

macrozone avatar Apr 17 '18 07:04 macrozone

agreed, I'm trying to see if there's a way to get the full node-plop API injected into the action which would be consistent and also give this more power. I'm not 100% sure that using the node-plop API is the right approach here, but I wanted to rule it out before moving forward with a hybrid API that is 99% the same as the plop API.

amwmedia avatar Apr 18 '18 20:04 amwmedia

We're moving the node-plop codebase into a monorepo. @macrozone if you want to re-open this PR over there, I'll be happy to re-review.

This repo will be archived in a short bit.

https://github.com/plopjs/plop/tree/master/packages/node-plop

crutchcorn avatar Apr 25 '22 22:04 crutchcorn