yeoman / yeoman-app

A desktop app that scaffolds projects using Yeoman
988 stars 106 forks source link

Issue with new yeoman-generator version #125

Open FrancoisDF opened 6 years ago

FrancoisDF commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@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.