plopjs / plop

Consistency Made Simple
http://plopjs.com
MIT License
7.06k stars 277 forks source link

enh: async dynamic generator actions #420

Open benallfree opened 6 months ago

benallfree commented 6 months ago

This update makes it possible to use a dynamic actions function that returns a promise. It's helpful for situations where building the final actions list requires async calls.

akaguny commented 5 months ago

i'm also need this feature! in logic that change looks like "simple dimple" change actions = actions(data); to actions = await actions(data); in the condition

    // if action is a function, run it to get our array of actions
    if (typeof actions === "function") {
      actions = await actions(data);
    }

if actions function is async then we wait, in another way nothing changed. yes, it can maybe be a little slowly, but is that really matter and if we have benchmarks we can check

benallfree commented 5 months ago

Yep and it seems to work 100%!

akaguny commented 5 months ago

@benallfree , you know what we should do for the next iteration of the implementation?

benallfree commented 5 months ago

The PR is ready & awaiting approval. What do you mean next iteration?