plopjs / plop

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

fix(node-plop): bypass list prompts with choices being a function #372

Open kkckkc opened 1 year ago

kkckkc commented 1 year ago

Fixes #224

While #224 is closed with a workaround, that workaround does not work for me as I rely on a series of list prompts where the available choices depends on previously selected values.

This PR provides a simple fix for handling the list prompt when the choices property is a function. We pass the previous answers into bypass function, and in listTypeBypass we check if choices is a function and in that case invokes it to get the available choices as an array

I suppose this can be extended to support checkboxes as well, but that goes beyond my immediate need.