yeoman promise

Solutions on MaxInterview for yeoman promise by the best coders in the world

showing results for - "yeoman promise"
Lisa
21 Jun 2017
1// at the begining of method call: const done = this.async()
2// when you are done call: done()
3//
4// for example:
5//
6
7const Generator = require('yeoman-generator')
8
9const questions = [
10    { type: 'input',
11      name: 'name',
12      message: 'What is the name of this form?',
13      default: 'someForm'
14    }
15]
16
17const names = [
18 {
19   type: 'input',
20   name: 'inputs',
21   message: 'What is the name of the input?',
22   default: '.input'
23 },
24 {
25   type: 'confirm',
26   name: 'another',
27   message: "Is there another input?",
28   default: true
29 }
30]
31
32const inputs = []
33
34class Form extends Generator {
35
36  prompting2 () {
37     const done = this.async()
38     return this.prompt(names).then((answers) => {
39      inputs.push(answers.inputs)
40      if (answers.another) this.prompting2()
41      else {
42       this.inputs = inputs
43       this.log(this.inputs)
44       done()
45      }
46    })
47  }
48
49}
50
51module.exports = Form