plopjs / plop

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

Can plop produce files based on json file inputs? #432

Open meleklassoued opened 7 months ago

meleklassoued commented 7 months ago

Description :

I want to generate some files using pre-prepared templates. I'd like to pass a JSON file to the prompt, which will allow for the direct generation of the templates based on its content.

amwmedia commented 7 months ago

You should be able to use the normal node API to load and parse data out of a JSON file and pass it to actions that you want to execute. Each Action supports a data prop as part of the API. An object passed to this prop will be merged with user answer data before running the action.

awhitford commented 1 month ago

I have this desire too -- to be able to import prompt values from a json file rather than use the command-line. (My workaround is to write a shell script that translates the json file into command-line parameters.)

I'm not really understanding the advice from @amwmedia. I see that each action supports a data property, but the json file should influence the prompts (not actions).