dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

UI Prompt called when already mid prompt #220

Open MatteoGabriele opened 7 years ago

MatteoGabriele commented 7 years ago

I've recently discovered this issue prompting an array of questions. It only happens after the first question and when ctrl + c is pressed to be able to go out the prompt.

.action(function (args, callback) {
  this.prompt([
    { ... }, // during this question is still possible to exist 
    { ... } // here pressing `ctrl + c` will cause the error
  ])
})

Error in the console

Error: UI Prompt called when already mid prompt.
    at UI.prompt (/web/blocklevel/blue-next/packages/bcli/node_modules/vorpal/dist/ui.js:209:15)
    at /web/blocklevel/blue-next/packages/bcli/node_modules/vorpal/dist/vorpal.js:571:19
    at Vorpal.vorpal.prompt (/web/blocklevel/blue-next/packages/bcli/node_modules/vorpal/dist/vorpal.js:546:10)
    at Session.session.prompt (/web/blocklevel/blue-next/packages/bcli/node_modules/vorpal/dist/session.js:132:22)
    at CommandInstance.prompt (/web/blocklevel/blue-next/packages/bcli/node_modules/vorpal/dist/command-instance.js:101:27)
    at pathExists.then.exists (/web/blocklevel/blue-next/packages/bcli/src/commands/_component.js:56:23)

OS: macOS Sierra node: 7.4.0 npm: 4.3.0 yarn: 0.21.3

MatteoGabriele commented 7 years ago

Well I have apparently fixed it chaining the cancel method after the action one

.cancel(function () {
   process.exit(1)
})

Don't know if this is the proper way but I'm not blocked anymore.

Up to you if you want to close the issue because maybe you want to handle this problem in a better way.

And btw terrific project! I really like it a lot!