unjs/consola

Concurrent interaction exception

wss-git opened this issue · 2 comments

Describe the feature

inoperable ‘Deploy to the production ’

const { consola } = require("consola");

(async () => {
  await Promise.all([
    a(),
    b(),
  ])
})()

async function a() {
  await consola.prompt("Deploy to the production?", {
    type: "confirm",
  });
}

async function b() {
  await consola.prompt("bbbbbb?", {
    type: "confirm",
  });
}

image

Additional information

  • Would you be willing to help implement this feature?

Do you mean that you want to make the 2 prompts operable at the same time and move cursor between them with up/down arrow keys?

If so, such a feature is not supported at least at the moment as far as I know.


By the way, generally, it is supposed to be that only one prompt is used at a time.

I'm no so sure how it happens but the prompt executed first seems to be answered as "yes" because the next prompt is executed and have a control on user input (note: "Yes" is default answer when initialValue option is not provided to a confirm prompt).

This happens because you use Promise.all() that awaits promises parallelly.
You should sequentially await confirm prompt promises.

const { consola } = require("consola");

(async () => {
  await a()
  await b()
})()

async function a() {
  await consola.prompt("Deploy to the production?", {
    type: "confirm",
  });
}

async function b() {
  await consola.prompt("bbbbbb?", {
    type: "confirm",
  });
}

e... It seems that our project is not very suitable for this thing anymore, we have such a scenario. Thank you for your reply