yeoman / environment

Yeoman runtime environment
BSD 2-Clause "Simplified" License
128 stars 70 forks source link

Capturing console output in generator #323

Closed barrettc closed 3 years ago

barrettc commented 3 years ago

I've written a custom generator that I'm integrating in another tool. I'm wondering if there's an easy way to construct my Yeoman environment to pass in my logger or somehow capture the output of my generator. For example, I'd like to be able to do something like:

const env = yeoman.createEnv()
env.register(require.resolve('generator-whatever'))
const results = await env.run('whatever')

And then have the output of the generator in my results instead of the results going to console.log. Thanks for any help!

mshima commented 3 years ago

You should take a look at adapter parameter passed to the environment, there is a console inside.