Last active
August 1, 2016 07:42
-
-
Save kristw/3aafb94875a1db08419f80cc32daf7e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ | |
... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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