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

again some problem with the name #2

Open
tunnckoCore opened this issue Jul 17, 2016 · 2 comments
Open

again some problem with the name #2

tunnckoCore opened this issue Jul 17, 2016 · 2 comments

Comments

@tunnckoCore
Copy link

tunnckoCore commented Jul 17, 2016

In combination with latest *-dest and *-package.

Like so https://asciinema.org/a/79981 (that screencast looks ugly, damn, maybe becaus emy new GUI)

I can see the sense in this behaving, but I think this should work too.

edit: and again not 100% sure if problem comes from here

@jonschlinkert
Copy link
Member

jonschlinkert commented Jul 17, 2016

thanks for the screencast. Hmm, I thought i fixed this.

I think this should work too.

It definitely should work - this is a bug. If you look at one of the demos on the readme, I'm doing this and it doesn't ask the questions more than once. I need to figure out why... there are two reasons I can think of.

In case this helps (so you can help me debug if you want).

Potential reason 1: new instances

Every generator function is a new instance of Generate. We do this to ensure that state is not shared across generators. Basically the equivalent of this (I know you're familiar with most of this, but maybe not the last part):

var Generate = require('generate');
var app = new Generate();

function generator(app) {

}
// when a generator is run, we do something like this
// before running the `default` task, or specified task on the generator
generate(app);

K, now the point is that doing the following will not share data across generators:

app.data(whatever);

To share data, we need to add data to app.base, which is a special "shared instance" of Generate:

app.base.data(whatever);

It's possible that the answers aren't adding the data to an object that is accessible by both generators, e.g. the app.base instance. I thought I was doing this, but I'm in a habit of using app.data() instead of app.base.data(), so it's very possible that I forgot to do this somewhere.

Potential reason 2: question property names

The ask helper might be asking the same question, but using different property names on each generator. I don't think this is it though, particularly since author.name is pretty specific, whereas "project name" might be on either name or project.name (fwiw I initially thought it was a good idea to use project.name, but realized that it would make it more difficult to just use package.json data as-is. So reverted back to using just name. Brilliant, right?)

@tunnckoCore
Copy link
Author

Hm. Yea, sounds more like a first reason to me too.

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