Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use hygen to get the string output only? #403

Open
yedeyu opened this issue Aug 3, 2022 · 0 comments
Open

Can I use hygen to get the string output only? #403

yedeyu opened this issue Aug 3, 2022 · 0 comments

Comments

@yedeyu
Copy link

yedeyu commented Aug 3, 2022

I want to get the string output only for each template within my program.

I tried the following code, and see that the log statements I added didn't run.

const { runner } = require('hygen')
const Logger = require('hygen/dist/logger').default
const path = require('path')
const defaultTemplates = path.join(__dirname, 'templates')

runner(process.argv.slice(2), {
  templates: defaultTemplates,
  cwd: process.cwd(),
  logger: new Logger(console.log.bind(console)),
  createPrompter: () => require('enquirer'),
  exec: (action, body) => {
    console.log(action);
    console.log(body);
    
    const opts = body && body.length > 0 ? { input: body } : {}


    //return require('execa').shell(action, opts)
  },
  debug: !!process.env.DEBUG
})

I tried the following code, and see the result is not the string content that I expected.

const { runner } = require('hygen')
const Logger = require('hygen/dist/logger').default
const path = require('path')
const defaultTemplates = path.join(__dirname, 'templates')

let p = runner(process.argv.slice(2), {
  templates: defaultTemplates,
  cwd: process.cwd(),
  logger: new Logger(console.log.bind(console)),
  createPrompter: () => require('enquirer'),
  debug: !!process.env.DEBUG
})

p.then(console.log);

So my question is, can I use hygen to get the string output only (for each template)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant