Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Prompt validator can't be async when using bypass #182

Closed
ThisIsMissEm opened this issue Aug 28, 2020 · 3 comments
Closed

Prompt validator can't be async when using bypass #182

ThisIsMissEm opened this issue Aug 28, 2020 · 3 comments
Labels

Comments

@ThisIsMissEm
Copy link

Inquirer allows for the prompt's validate function to be asynchronous, however, when Plop prompt-bypass function calls the validator for the prompt, it does not allow for this and expects all validators to return a boolean or string.

Example

  plop.setGenerator('user', {
    description: 'Add a new user',
    prompts: [
      {
        name: 'username',
        message: 'What is the user name?',
        type: 'input',
        validate: async (input) => {
          // do something async, returning either a boolean or string;
        },
      },
    ], 
    actions: []
  })

Calling with plop user works, but plop user thisismissem fails with [ERROR] [object Promise]

@amwmedia amwmedia added the bug label Aug 28, 2020
@amwmedia
Copy link
Member

Agreed, this must have been an oversight when we built the bypass functionality.

@crutchcorn
Copy link
Member

This issue is being fixed, with tests to verify, in node-plop@0.13 and plop@3. Tracking PR: #212

@crutchcorn
Copy link
Member

This has now been released as-of Plop 3!

https://github.com/plopjs/plop/releases/tag/v3.0.0

@crutchcorn crutchcorn reopened this Nov 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants