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

Select mode returns 1 for falsy values #187

Closed
tomchambers2 opened this issue Aug 9, 2019 · 0 comments
Closed

Select mode returns 1 for falsy values #187

tomchambers2 opened this issue Aug 9, 2019 · 0 comments

Comments

@tomchambers2
Copy link

Describe the bug

You can't get a true/false out of the select choices. I realise you could use the confirm prompt in many cases, but in my case I want a yes/no/quit dialog. However false or 0 returns 1 as the selection.

To Reproduce

const prompts = require("prompts");

const test = async () => {
  const data = await prompts({
    type: "select",
    name: "test",
    message: `do you like ice cream`,
    choices: [
      {
        title: "Yes",
        value: true
      },
      { title: "No", value: false },
      { title: "Third random option", value: 'other' },
    ]
  });

  console.log(data);
};

test();

Results

selene:social-graph-2 tomchambers$ node tools/test.js 
✔ do you like ice cream › No
{ test: 1 }
selene:social-graph-2 tomchambers$ node tools/test.js 
✔ do you like ice cream › Yes
{ test: true }
selene:social-graph-2 tomchambers$ 
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