// The name `constructor` is important here constructor(args, opts) { // Calling the super constructor is important so our generator is correctly set up super(args, opts) this.argument('generatorName', { type: String, required: false }) if (this.options.generatorName) { this.generatorName = _.kebabCase(this.options.generatorName) } }
prompting() { const prompts = [] if (!this.options.generatorName) { prompts.push({ type: 'input', name: 'generatorName', message: 'What would like to name this generator?', validate: (input) => { if (input.length <= 0) { return 'You must provide a generator name' } return true } }) } return this.prompt(prompts).then((answers) => { if (answers.generatorName) { this.generatorName = _.kebabCase(answers.generatorName) } }) }