janji yeoman

// at the begining of method call: const done = this.async()
// when you are done call: done()
//
// for example:
//

const Generator = require('yeoman-generator')

const questions = [
    { type: 'input',
      name: 'name',
      message: 'What is the name of this form?',
      default: 'someForm'
    }
]

const names = [
 {
   type: 'input',
   name: 'inputs',
   message: 'What is the name of the input?',
   default: '.input'
 },
 {
   type: 'confirm',
   name: 'another',
   message: "Is there another input?",
   default: true
 }
]

const inputs = []

class Form extends Generator {

  prompting2 () {
     const done = this.async()
     return this.prompt(names).then((answers) => {
      inputs.push(answers.inputs)
      if (answers.another) this.prompting2()
      else {
       this.inputs = inputs
       this.log(this.inputs)
       done()
      }
    })
  }

}

module.exports = Form
Clean Cod