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

Add shared storage for generators. #56

Closed
wants to merge 1 commit into from
Closed

Add shared storage for generators. #56

wants to merge 1 commit into from

Conversation

jamen
Copy link

@jamen jamen commented Mar 14, 2016

This is so sub-generators (or a collection of similarly-authored generators) can depend on shared data if needed... It relies on a module already in the dependency tree (dependency of a dependency) and is a small addition that enables a powerful subset style of generating, so I see no harm done.

Say for instance, I have foo, with foo:bar and foo:qux that both render different files that require name... If we run these at the same time:

$ yo foo:bar, foo:qux

You can prompt for the data one time (both generators foo:bar and foo:qux):

prompting: function() {
  if (!this.env.share.has('name')) {
    this.prompt({ ... }, function(res) {
      this.env.share.set('name', res.name);
    });
  }
}

Yet both generators can still retrieve the name later, with this.env.shared.get('name'), without having to reprompt the user.

The module I used, es6-map, was already in the dep tree, so I'm just reusing it here in a small implementation.

Closes yeoman/yo#416

@SBoudrias
Copy link
Member

Hey, thanks for sending a PR. It is appreciated.

Unfortunately, this suggestion is not something I'm comfortable with going forward. Global values absent clearly defines structures always become a maintenance nightmare. This would impact users relying on this feature, but also our ability to push updates to our platform in the future.

@jamen
Copy link
Author

jamen commented Mar 15, 2016

Alright, no problem. It was worth a shot. :P

@jamen jamen mentioned this pull request Aug 28, 2016
3 tasks
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

Successfully merging this pull request may close these issues.

None yet

2 participants