Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I bypass a prompt when I already have an answer? #450

Closed
AllanOricil opened this issue Sep 27, 2024 · 1 comment
Closed

How can I bypass a prompt when I already have an answer? #450

AllanOricil opened this issue Sep 27, 2024 · 1 comment

Comments

@AllanOricil
Copy link

AllanOricil commented Sep 27, 2024

I tried node-plop await generator.runPrompts(["projectName"]), where

prompts: [
      {
        type: "input",
        name: "projectName",
        message: "Project name?",
        default: "nrg-project",
      },
]

but it did not work. I keep getting the following error

TypeError: String.prototype.split called on null or undefined
    at split (<anonymous>)
    at travel (file:///Users/allanoricil/nrg-cli/node_modules/inquirer/lib/ui/prompt.js:19:10)
    at Object.get (file:///Users/allanoricil/nrg-cli/node_modules/inquirer/lib/ui/prompt.js:26:20)
    at PromptUI.filterIfRunnable (file:///Users/allanoricil/nrg-cli/node_modules/inquirer/lib/ui/prompt.js:158:9)
    at doInnerSub (/Users/allanoricil/nrg-cli/node_modules/rxjs/dist/cjs/internal/operators/mergeInternals.js:22:31)
    at outerNext (/Users/allanoricil/nrg-cli/node_modules/rxjs/dist/cjs/internal/operators/mergeInternals.js:17:70)
    at OperatorSubscriber._this._next (/Users/allanoricil/nrg-cli/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:33:21)
    at Subscriber.next (/Users/allanoricil/nrg-cli/node_modules/rxjs/dist/cjs/internal/Subscriber.js:51:18)
    at /Users/allanoricil/nrg-cli/node_modules/rxjs/dist/cjs/internal/operators/mergeInternals.js:28:28
    at OperatorSubscriber._this._next (/Users/allanoricil/nrg-cli/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:33:21)
Waiting for the debugger to disconnect...

This debugger views show what happens after await promptBypass. Look at the values displayed in the debugger
image

This debugger view show the internal execution of the promptBypass.
image

In your tests, after calling promptBypass, you verify the input values of each bypassed prompt, for example:

const [promptsAfterBypassTwo, bypassTwo] = await promptBypass(
      prompts,
      ["b", "something"],
      plop,
);
expect(bypassTwo.list).toBe("B");
expect(bypassTwo.input).toBe("something");
expect(promptsAfterBypassTwo.length).toBe(4);

However, in the run I shared above, it is clear that there is no "input" property in the bypassed prompt, inside bypassAnswers, which is equivalent to your bypassTwo. So, what is going wrong?

I'm using [email protected] and [email protected]

@AllanOricil
Copy link
Author

relates to #445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant