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

Separate the core and the generator instances #315

Closed
SBoudrias opened this issue Jul 12, 2013 · 5 comments
Closed

Separate the core and the generator instances #315

SBoudrias opened this issue Jul 12, 2013 · 5 comments

Comments

@SBoudrias
Copy link
Member

At the moment, every Yeoman helper function is directly linked to the generator instance (this.write, this.log, this.spawn, etc).

This is good for a lot of them as they need to be executed in context, but for a lot of other methods, that's not really the case.

I wonder if it wouldn't be cleaner to separate the generator instances from the utility functions. And instead of calling this.spawn, being able to call yo.spawn.

I haven't check exactly which methods are context independent, so maybe there's not enough to make it worthwhile.

@SBoudrias
Copy link
Member Author

Checked a bit while coding today, and there's already three modules being inserted out of the generator context here: https://github.com/yeoman/generator/blob/master/lib/base.js#L92-L94 - so they're #1 candidates.

And then I realized that really only the actions.js module is hardly linked to the generator instance (because it uses paths variables to prefix his action). Most of the others helpers modules really are mostly standalone helpers.

I believe this would be cleaner than using instances methods (plus it liberate devs from the hassle of this binding for free).

@addyosmani
Copy link
Member

I'm 👍 to us opting for moving towards instance methods.

@sindresorhus
Copy link
Member

👍

@SBoudrias SBoudrias added feature and removed next labels Aug 7, 2014
@SBoudrias SBoudrias modified the milestones: 1.1, 1.0.0 Aug 14, 2014
@SBoudrias SBoudrias removed this from the 1.0.0 milestone Nov 26, 2016
@MarcoScabbiolo
Copy link
Contributor

plus it liberate devs from the hassle of this binding for free

That sounds like a good enough reason for me!

On top of decoupling the utility methods from the Generator instance it would be nice to auto-bind the methods that need to run in the context of the Generator so we can pass them around without having to bind them every time.

Decoupling may take some effort but just binding the methods shouldn't take so much, I could do it if everybody is OK with the idea.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2020

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the stale label Jan 2, 2020
@github-actions github-actions bot closed this as completed Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants