node.jscode-generationyeomanyeoman-generatorinquirerjs

How do I register an inquirer.js plugin for a yeoman generator prompt?


When authoring a yeoman generator, I'd like to use the 'autocomplete' plugin for inquirer (https://github.com/mokkabonna/inquirer-autocomplete-prompt) in one of my prompts. I can't seem to find anything in the docs that says how to register this plugin with inquirer from within the yeoman generator. Is this possible?


Solution

  • found the answer :

    module.exports = class extends Generator {
      initializing() {
        this.env.adapter.promptModule.registerPrompt("autocomplete", require("inquirer-autocomplete-prompt"));
      }
    }