node-plop
node-plop copied to clipboard
allow to execute subactions
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.
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?
I think its worth it. Its not the most beautiful api, but it works and solve some issues
I'm going to spend a little time with this... I think it needs to get merged in one form or another. :+1:
i merged master back in. Hope you can take a look soon!
any chance to get this merged? its tested and solves some issues
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 any updates ;-) i know, its not the best to reinvent a new api, but its a pragmatic approach
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.
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