SamKirkland / plop-templates

VSCode extension for plop.js file templates
MIT License
22 stars 5 forks source link

No prompt for generator when multiple generators configured #15

Closed pseudoramble closed 2 years ago

pseudoramble commented 2 years ago

Hi there - thanks for the plugin. Hoping to get it working soon!

I currently have two generators configured in my plopfile, using setGenerator with standard prompts. When using the plugin to create a new file, it thinks there is only generator "A" below and immediately jumps to that one.

Here's what plopfile.js looks like:

  plop.setGenerator('A', {
    actions: [...],
    description: 'A.',
    prompts: [
      {
          // You should always include a "destinationpath" prompt when using this extension
          // this extension will automatically answer this prompt for the user.
          // Which allows your plop file to be placed in the correct location
          type: "input",
          name: "destinationpath",
          message: "Template destination path"
      },
      ...
    ],
  });

  plop.setGenerator('B', {
    actions: [...],
    description: 'B.',
    prompts: [
      {
          // You should always include a "destinationpath" prompt when using this extension
          // this extension will automatically answer this prompt for the user.
          // Which allows your plop file to be placed in the correct location
          type: "input",
          name: "destinationpath",
          message: "Template destination path"
      },
      ...
    ],
  });

I confirmed that plop itself is able to detect the generators and can create files successfully using that. I also confirmed that calling plop.getGeneratorList() is able to see all of the generators after they're setup, which should match what's happening in the code too.

Any suggestions on what else to look at to debug? Should I setup the plopfile somewhat differently for this plugin?

pseudoramble commented 2 years ago

Welp, I now feel a bit foolish for now having tried this before, but simply restarting VS Code seems to have caused it to reload the plopfile and find the generators and worked as expected. If you're adding or modifying the name of a generator, restart VSC to pick up the changes.

I do wonder if it's possible to have it reload the plop file more dynamically than this though? It would be nice to add new generators without a reboot.

airtonix commented 2 years ago

I do wonder if it's possible to have it reload the plop file more dynamically than this though? It would be nice to add new generators without a reboot.

yes it's totally possible.