Bert
Bert

Reputation: 350

Create yeoman generator from json instead of prompts?

When I create a project, I first create a project.json file (used internally, not as part of some package). Then for some projects I run yeoman with our own custom generators. What I would like is for yeoman to pick up my projects.json and read that instead of prompting me for settings. Is this possible, and if so; how do I do this? Basically I think I need to know:

  1. How do I load the file from the project-root into index.js (and defer to prompts if it doesn't exist)
  2. How to I bind the properties from the json to 'this'.

Upvotes: 1

Views: 819

Answers (1)

Simon Boudrias
Simon Boudrias

Reputation: 44669

A Yeoman generator is just a searchable and composable Node.js project running within the context of Yeoman.

As so, it can do anything.

So, if you want to write a generator reading a project.json configuration file to know what to generate - well just do it!

http://yeoman.io/authoring/

Upvotes: 1

Related Questions