How to use the hygen code generator
How to use the Hygen code generator
There are platforms that list thousands of generators namely yeoman but often you will need something simple and custom. The alternative is to use Hygen for generating custom project sections.
Start with creating the project
Saving will create your personal copy
Then you can open a new terminal.
Initialize Hygen generator
Write into the following command into the terminal.
npx hygen init self
you should see an output like this.
Now we have a generator that will be used to create other generators
Generate a with-prompt generator
We will be using prompt to ask questions in the console. See examples of prompts using enquirer.
npx hygen generator with-prompt readme
Now we can change the template files
Update _templates/readme/with-prompt/hello.ejs.t to:
--- to: README.md --- # <%= name %>
<%= message %>
Update _templates/readme/with-prompt/prompt.js to: