Skip to content

Instantly share code, notes, and snippets.

@kristw
Last active August 1, 2016 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristw/3aafb94875a1db08419f80cc32daf7e1 to your computer and use it in GitHub Desktop.
Save kristw/3aafb94875a1db08419f80cc32daf7e1 to your computer and use it in GitHub Desktop.
prompting: function () {
// Have Yeoman greet the user.
// Would love to skip this if this generator is called from another generator.
this.log(yosay(
'Welcome to the <%- superb %> ' + chalk.red('<%= generatorName %>') + ' generator!'
));
var prompts = [{
type: 'confirm',
name: 'someAnswer',
message: 'Would you like to enable this option?',
default: true
}];
// Have to do this promise handling every time
// to store the answers into this.props
return this.prompt(prompts).then(function (props) {
// To access props later use this.props.someAnswer;
this.props = props;
}.bind(this));
},
writing: {
if(this.props.someAnswer){
...
}
}
prompting: function () {
// Will skip this if options.skipGreeting is true
this.easily.greet(
'Welcome to the <%- superb %> ' + chalk.red('<%= generatorName %>') + ' generator!'
);
return this.easily
.confirmBeforeStart('Would you like to enable this option?')
.prompt();
},
writing: {
if(this.easily.checkForConfirmation()){
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment