jondot / hygen

The simple, fast, and scalable code generator that lives in your project.

Home Page:http://www.hygen.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I access Helpers from Prompts?

ajoslin103 opened this issue · comments

I want to only ask for inputs if I don't already have them

const h = require('hygen/helpers') // <===== Error: Cannot find module 'hygen/helpers'
module.exports = [
  {
    type: 'input',
    name: 'dev_email',
    message: "Please enter your dev_email prior to the @ symbol, which Kubernetes doesn't allow in string fields:",
    skip: () => h.isLocal('dev_email')
  },

Of course that would mean that helpers had access to local variables defined within the hygen execution

const locals = require('hygen/locals') // <===== Error: Cannot find module 'hygen/locals'
module.exports = {
    helpers: {
        isLocal: tag => !!locals[tag]
    }
}

How to I access the execution space of the interpolater? It has all the data I need?

this is mostly answered here: https://www.hygen.io/docs/generators#advanced-interactive-prompt

some additional details can be found here: #35 (comment)

my use case was satisfied, thanks for a great tool 👍