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

Refactoring and imbricate generator #491

Closed
mazerte opened this issue Feb 7, 2014 · 4 comments
Closed

Refactoring and imbricate generator #491

mazerte opened this issue Feb 7, 2014 · 4 comments

Comments

@mazerte
Copy link

mazerte commented Feb 7, 2014

Hi,

I work on my generator footguard and each release of yeoman generator break my code. Is because I don't use the good feature of yeoman.

In footguard, for generator a backbone collection I use yo footguard:collection people and the generator ask my if I want to create the associate model. And I have a generator for this yo footguard:model person. But I don't understand how to use the model generator in the collection generator.

I try to instantiate the model generator in the collection generator but it's very complex to pass the env to the second generator. Each release break this hack, it's not the idea. After I try to use the test helper for do this. I call helpers.createGenerator and I pass arguments and answer with helpers.mockPrompt. I thinks it's good idea because this part of code is always tested.

But two day I pull this master of yeoman generator and this feature don't work.

What is the good way for do that ?

PS: my projet work on 0.16.0 but not on master

You can see the bug on my prompt branch.

I have an other problem for this line base.js#L377 because it always install dependencies after sub-generator call.

Thanks for your help.

Mathieu

@mazerte
Copy link
Author

mazerte commented Feb 7, 2014

The line where I create the imbricate generator.
https://github.com/mazerte/generator-footguard/blob/prompt/footguard-base.js#L130

@SBoudrias
Copy link
Member

Hey, helpers namespace is used for testing utility methods. That's why it may seems odd to use it this way.

Currently, there's no easy way to do what you're trying to do. We're currently working to fix that, see #484 and #485.

ATM though, the best way would probably to call the extra generator in a hook (this.hookFor()) or to run it directly this.env.run('gen:sub'). There's no easy way to mock prompt options, so you should just make the sub-generator accept command line options for each prompt options too, and then you provide those options to the env#run method.

@mazerte
Copy link
Author

mazerte commented Feb 11, 2014

Thanks Simon,

I re-implement my method like this https://github.com/mazerte/generator-footguard/blob/prompt/footguard-base.js#L130 and it's work.

You can close this issues if you want. Or keep it open for composeWith history.

Mathieu

@SBoudrias
Copy link
Member

I'll close as we're going to keep track of composability façade on the other issue.

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

2 participants