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

Issue with new yeoman-generator version #125

Open
FrancoisDF opened this issue Sep 11, 2017 · 3 comments
Open

Issue with new yeoman-generator version #125

FrancoisDF opened this issue Sep 11, 2017 · 3 comments

Comments

@FrancoisDF
Copy link

FrancoisDF commented Sep 11, 2017

I could not get any generators working that were using yeoman-generator@^1.0.0.
I keep getting the following error:

TypeError: Cannot read property 'then' of undefined
    at <generator_name>.Base.prompt (.../node_modules/<generator_name>/node_modules/yeoman-generator/lib/index.js:168:44)

(generator-licence is an easy one to test)

@FrancoisDF
Copy link
Author

FrancoisDF commented Sep 11, 2017

Starting from yeoman-generator@v0.23.0, Base#prompt() functions now returns a promise instead of taking a callback parameter:

prompting: function () {
   return this.prompt(questions).then(function (answers) {
    this.answers = answers;
  }.bind(this));
}

So I think the adapter need to be updated to use a promise instead of a callback. Or maybe returning both to be compatible with more generators.

@FrancoisDF
Copy link
Author

FrancoisDF commented Sep 19, 2017

FIX
In yo/adapter.js

ProcessAdapter.prototype.prompt = function (questions, callback) {
  process.send({
    event: 'generator:prompt-questions',
    data: questions
  });

  if (callback){
    this.answerCallback = callback;
  } else {
    return new Promise((resolve) => {
      this.answerCallback = resolve;
    });
  }
};

@SBoudrias
Copy link
Member

@R0muald do you want to send a PR?

This project isn't actively maintained anymore, but I'll gladly help you get some fixes in.

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