plop
plop copied to clipboard
Can't bypass a checklist prompt without selecting at least one option
Example Repo
Bypassing Checklist Prompts With No Options Selected
I created a minimal reproduction of the issue by creating a pizza
generator where you select from three possible toppings.
The goal is to be able to bypass the checklist
prompt and select none of the toppings.
Or in pizza terms, I want to order a cheese pizza. 🍕
npm run plop
? Choose your toppings. (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
>( ) pepperoni
( ) sausage
( ) onions
PASS
npm run plop pepperoni
✔ -> {"toppings":["pepperoni"]}
PASS
npm run plop pepperoni,sausage,onions
✔ -> {"toppings":["pepperoni","sausage","onions"]}
FAIL
In this case, I would expect to be able to bypass the checklist
prompt by including something like an empty string (""
) or an empty array ([]
).
npm run plop ""
✔ -> {"toppings":[]}
May you need to hide toppings with when:false
property based on previous value selected.
In my actual use case, the prompt in question doesn't rely on previous prompts, much like this pizza example.
yeah, it look like we need to add a case in the checkbox logic for passing "no value". we split the input value on ,
, so I think it would make sense to just check for an array of length 1
, containing an empty string.
https://github.com/plopjs/plop/blob/master/packages/node-plop/src/prompt-bypass.js#L82
Thanks for pointing me in the right direction @amwmedia, I'll get a pull request up soon!
I opened #354 to address this issue, I hope it covers the use case!
/cc @amwmedia @crutchcorn