I am trying to understand the this.async()
pattern within yeoman generators and I came across something confusing within the generator-generator code:
https://github.com/yeoman/generator-generator/blob/master/app/index.js#L108-L111
Up until now I've been using this:
var done = this.async();
// do some stuff...
done();
But what does passing true
and false
to done() do?
In this case, done
and this.async()
are for an inquirer
prompt
, which Yeoman's this.prompt()
wraps.
Within the prompt
's when
handler, the argument determines whether or not to display the prompt to the user:
- when: (Function) Receive the current user answers hash and should return
true
orfalse
depending on whether or not this question should be asked.